I have a dialog box in a .dlg file controlled by a python script and I need to disable or enable some of the controls depending on whether a checkbox is on/off.
Now I have a solution where these parts are visible or invisible (listener action - setVisible(True/FALSE) and this works properly. But if I change it to setEnabled(True/False), AttributeError appear.. ( (<class 'AttributeError'>: setEnabled). Is any solution please? Thank you
Code: Select all
def itemStateChanged(self, itemEvent):
# Get the checkbox state (ckbAllContactsOfInvoices, ckbFirmsVerify)
source = itemEvent.Source
# Get the name of the checkbox
source_name = itemEvent.Source.Model.Name
if source_name == "ckbAllContactsOfInvoices":
if source.State == 1:
self.cmb_days_back.setVisible(False)
self.lbl_days_back.setVisible(False)
else:
self.cmb_days_back.setVisible(True)
self.lbl_days_back.setVisible(True)
elif source_name == "ckbFirmsVerify":
if source.State == 1:
self.txt_firms.setVisible(True)
else:
self.txt_firms.setVisible(False)