Reputation: 128
I have three radioButtons, which shall select preselect time intervals 1s 10s and any. I created the following connects, but I get the error message that argument 1 has unexpected type 'NoneType'
self.radioButton_1s.clicked.connect(self.setInterval(1))
self.radioButton_10s.clicked.connect(self.setInterval(10))
self.radioButton_any.clicked.connect(self.setInterval(0))
Doing an int-cast like self.setInterval(int(1)) doesn't make a difference.
The called method is the following. I know that the math isn't tight, but thats not the problem. Normaly the doubleSpinBox reads values like 0.25 0.1 or similar.
@QtCore.pyqtSlot()
def setInterval(self,i):
if i == 1:
n = 1/self.doubleSpinBox_TimeIndexStep.value() #TODO: use math.floor/ceiling to geht integers
self.spinBox_CopyInterval.setEnabled
self.spinBox_CopyInterval.setValue(n)
elif i == 10:
n = 10/self.doubleSpinBox_TimeIndexStep.value()
self.spinBox_CopyInterval.setEnabled
self.spinBox_CopyInterval.setValue(n)
What do I have to change to set the value right?
Upvotes: 2
Views: 1555
Reputation: 76194
connect
looks to me like your typical callback registration function. It expects to get a function or callable, but you're passing in the return value of setInterval
, which is None
.
If you want the radio button to call setInterval
when it is selected, you need to create a function which will call setInterval
, and pass that as the argument to connect
instead. The shortest way to do that is with a lambda.
self.radioButton_1s.clicked.connect(lambda *args: self.setInterval(1))
Upvotes: 4