How to transmit value using button
11 Jan 2021 19:15 #194937
by aleksamc
How to transmit value using button was created by aleksamc
I've created keyboard using this
topic
in PyQtPyvcp.
The source value is "displayLabel" value of type QLabel.
I want to transmit this value using some button to type HalQSpinbox with some name.
So in short in differentwords:
I want to use touch screen, so I created keyboard.
I want to move value from keyboard to HalQSpinbox.
There are will be few HalQSpinbox and for each one will be button.
I imagine it like this (in mainwindow.py):
How I should finnish it?
The source value is "displayLabel" value of type QLabel.
I want to transmit this value using some button to type HalQSpinbox with some name.
So in short in differentwords:
I want to use touch screen, so I created keyboard.
I want to move value from keyboard to HalQSpinbox.
There are will be few HalQSpinbox and for each one will be button.
I imagine it like this (in mainwindow.py):
self.wr_len.clicked.connect(self.WriteLength) #for button wr_len
def WriteLength(self,button):
text = self.displayLabel.text()
self.stone_length.value(text) << I get error "TypeError: value(self): too many arguments"
How I should finnish it?
Please Log in or Create an account to join the conversation.
11 Jan 2021 23:33 #194984
by BigJohnT
Replied by BigJohnT on topic How to transmit value using button
You need to convert the text to a number with for example int() and it value IIRC returns the value not set the value. You need to use setValue(). You might also do some checking to make sure the text is a digit...
JT
JT
Please Log in or Create an account to join the conversation.
12 Jan 2021 06:06 - 12 Jan 2021 06:34 #195012
by aleksamc
Replied by aleksamc on topic How to transmit value using button
Thanks it's work, BigJongT.
I wrote such code:
Now I wonder, I have 4 such buttons, with this code and I needto copy this code for each button. My knowledge in Python vanish to zero. But I studied C++ a lone time ago and there was arguments.
How to write arguments in this code in such way that I could change "stone_length" to arg and to use it with different buttons?
After some time
I see that int() doesn't converts '3.3' to integer, I get eror
I wrote such code:
self.wr_len.clicked.connect(self.WriteLength)
def WriteLength(self,button):
if len(self.displayLabel.text()) >0:
text = int(self.displayLabel.text())
if text > 0:
self.stone_length.setValue(text)
else:
self.stone_length.setValue(0)
Now I wonder, I have 4 such buttons, with this code and I needto copy this code for each button. My knowledge in Python vanish to zero. But I studied C++ a lone time ago and there was arguments.
How to write arguments in this code in such way that I could change "stone_length" to arg and to use it with different buttons?
After some time
I see that int() doesn't converts '3.3' to integer, I get eror
ValueError: invalid literal for int() with base 10: '34.4'
Last edit: 12 Jan 2021 06:34 by aleksamc.
Please Log in or Create an account to join the conversation.
Time to create page: 0.081 seconds