jkrienert
20th January 2015, 14:38
A push button is checkable (setCheckable(True)), and when it is checked - a method is called to establish a value. If I manually uncheck (2nd click) the button, [bool=False] <<=ideally.
Unfortunately, the second check merely reinstates the [bool=True] value. Is there any means of checking the state of a button, ergo; if-down = return True, if-up = return False?
Relevant code:
...
self.pushButtonSetBase.setCheckable(True)
self.pushButtonSetBase.toggled.connect(self.on_pus hButtonSetBase_toggled)
...
@QtCore.pyqtSlot()
def on_pushButtonSetBase_toggled(self):
if self.pushButtonSetBase.isChecked:
print 'update the base!'
self.rowOverride = True
elif not self.pushButtonSetBase.isChecked:
print 'no base updates allowed!'
self.rowOverride = False
...
Probably a simple solution - but seems to be a struggle @ current.
Thousand thanks.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Added after 23 minutes:
[B]UPDATE:
This pyQt business is tricky... and fun.
Here is the working solution for anyone interested in the future.
...
self.pushButtonSetBase.setCheckable(True)
self.pushButtonSetBase.toggled.connect(self.on_pus hButtonSetBase_toggled)
...
@QtCore.pyqtSlot(bool) #<<== the missing link
def on_pushButtonSetBase_toggled(self,checked):
if checked:
print 'update the base!'
self.rowOverride = True
elif not checked:
print 'no base updates allowed!'
self.rowOverride = False
...
Unfortunately, the second check merely reinstates the [bool=True] value. Is there any means of checking the state of a button, ergo; if-down = return True, if-up = return False?
Relevant code:
...
self.pushButtonSetBase.setCheckable(True)
self.pushButtonSetBase.toggled.connect(self.on_pus hButtonSetBase_toggled)
...
@QtCore.pyqtSlot()
def on_pushButtonSetBase_toggled(self):
if self.pushButtonSetBase.isChecked:
print 'update the base!'
self.rowOverride = True
elif not self.pushButtonSetBase.isChecked:
print 'no base updates allowed!'
self.rowOverride = False
...
Probably a simple solution - but seems to be a struggle @ current.
Thousand thanks.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Added after 23 minutes:
[B]UPDATE:
This pyQt business is tricky... and fun.
Here is the working solution for anyone interested in the future.
...
self.pushButtonSetBase.setCheckable(True)
self.pushButtonSetBase.toggled.connect(self.on_pus hButtonSetBase_toggled)
...
@QtCore.pyqtSlot(bool) #<<== the missing link
def on_pushButtonSetBase_toggled(self,checked):
if checked:
print 'update the base!'
self.rowOverride = True
elif not checked:
print 'no base updates allowed!'
self.rowOverride = False
...