Page 1 of 1

[Solved] Dialog - setEnabled instead of setVisible?

Posted: Mon Apr 01, 2024 11:58 am
by sumec83
Hi everyone,

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)
                

Re: Dialog - setEnabled instead of setVisible?

Posted: Mon Apr 01, 2024 12:48 pm
by JeJe
Its setEnable not setEnabled - use MRI and you can easily find out for yourself.

viewtopic.php?t=49294

Re: Dialog - setEnabled instead of setVisible?

Posted: Tue Apr 02, 2024 7:38 am
by sumec83
Ooo thank you very much! I'm surprised but this works properly!
But I thought I had already tried that and it didn't work. So I don't know where I went wrong 🤨