[Solved] Dialog - setEnabled instead of setVisible?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
sumec83
Posts: 3
Joined: Tue Sep 26, 2023 8:43 am

[Solved] Dialog - setEnabled instead of setVisible?

Post 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)
                
Last edited by Hagar Delest on Tue Apr 02, 2024 7:54 am, edited 1 time in total.
Reason: tagged Issue.
Libreoffice 7.5.x on macOS 13.5.2 (arm)
JeJe
Volunteer
Posts: 2787
Joined: Wed Mar 09, 2016 2:40 pm

Re: Dialog - setEnabled instead of setVisible?

Post by JeJe »

Its setEnable not setEnabled - use MRI and you can easily find out for yourself.

viewtopic.php?t=49294
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
sumec83
Posts: 3
Joined: Tue Sep 26, 2023 8:43 am

Re: Dialog - setEnabled instead of setVisible?

Post 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 🤨
Libreoffice 7.5.x on macOS 13.5.2 (arm)
Post Reply