Page 1 of 1

[DONE] Button enabler

Posted: Mon Mar 10, 2008 12:24 pm
by Pako
I have need option Enable/Disable buttons (Test, OK and Apply) after checking validity data in panel.
Seems, that for example

Code: Select all

    def ButtonEnabler(self,flag=True):
        self.dialog.buttonRow.okButton.Enable(flag)
        self.dialog.buttonRow.testButton.Enable(flag)
        if flag and self.isDirty:
            self.dialog.buttonRow.applyButton.Enable(True)
        else:
            self.dialog.buttonRow.applyButton.Enable(False)
added to ConfigPanel.py, work fine.
Pako

Re: Button enabler

Posted: Mon Mar 10, 2008 1:26 pm
by Bitmonster
I have added it this way to the latest beta:

Code: Select all

    def EnableButtons(self, flag=True):
        """
        Enables/Disables the OK, Apply and Test buttons.
        
        Useful if you want to temporarily disable them, because the current
        settings have no valid state and later re-enable them.
        """
        buttonRow = self.dialog.buttonRow
        buttonRow.okButton.Enable(flag)
        buttonRow.testButton.Enable(flag)
        if flag and self.isDirty:
            buttonRow.applyButton.Enable(True)
        else:
            buttonRow.applyButton.Enable(False)

Re: [DONE] Button enabler

Posted: Mon Mar 10, 2008 1:31 pm
by Pako
Thanks !!! :)
Pako

Re: [DONE] Button enabler

Posted: Tue Mar 11, 2008 2:09 pm
by Bartman
what about a config panel wide validator routine like individiual control have them.
Is this possible?
Could reduce the amount of neccessary bindings.

Re: [DONE] Button enabler

Posted: Tue Mar 11, 2008 2:17 pm
by Bitmonster
A wx.Panel doesn't have a Validator option. Only individual controls allow them.

Re: [DONE] Button enabler

Posted: Tue Mar 11, 2008 2:28 pm
by Bartman
ah ok. I was not sure.