Attached is the py script and a small icon to run it.
Enter any character in the text control: the check box is properly enabled, but the button (a wx.lib.buttons.ThemedGenBitmapTextButton) is not, although it should.
If using a regular wx.Button, it works.
The problem is only when done through the EVT_UPDATE_UI event. If enabling/disabling it 'by hand' (self.myButton.Enable(False)), that works ok.
What's wrong ?
Running python 2.6.4, wxPython 2.8.10.1 on Windows XP
There's a bug in the declaration of the Enable function in wxPyControl, so when wx is calling it after the update ui event handler it is not passing the call on to the everridden Enable in the generic button class. IOW, the widget is being properly enabled/disabled because the call will go to the base class (try clicking on the button to verify) but on Windows it is not redrawing the widget in the altered state. You can work around it like this:
Attached is the py script and a small icon to run it.
Enter any character in the text control: the check box is properly
enabled, but the button (a wx.lib.buttons.ThemedGenBitmapTextButton) is
not, although it should.
If using a regular wx.Button, it works.
The problem is only when done through the EVT_UPDATE_UI event. If
enabling/disabling it 'by hand' (self.myButton.Enable(False)), that
works ok.
Attached is the py script and a small icon to run it.
Enter any character in the text control: the check box is properly
enabled, but the button (a wx.lib.buttons.ThemedGenBitmapTextButton) is
not, although it should.
If using a regular wx.Button, it works.
The problem is only when done through the EVT_UPDATE_UI event. If
enabling/disabling it 'by hand' (self.myButton.Enable(False)), that
works ok.
What's wrong ?
There's a bug in the declaration of the Enable function in wxPyControl, so when wx is calling it after the update ui event handler it is not passing the call on to the everridden Enable in the generic button class. IOW, the widget is being properly enabled/disabled because the call will go to the base class (try clicking on the button to verify) but on Windows it is not redrawing the widget in the altered state. You can work around it like this:
On Thu, Mar 11, 2010 at 11:11 PM, Robin Dunn <robin@alldunn.com> wrote:
There's a bug in the declaration of the Enable function in wxPyControl, so
when wx is calling it after the update ui event handler it is not passing
the call on to the everridden Enable in the generic button class.
I seem to remember writing a patch and creating a trac ticket for this
some time back to expose the wxWindow::Enable virtual method to python
subclasses. To fix an issue of calling Enable(False) on a Panel
wouldn't end up calling any overridden Enable methods in the child
controls of the Panel.
The problem was that Enable is declared like this:
virtual bool Enable( bool enable = true );
So the *_BOOL_BOOL version of the macros needed to be used for the overload to match the signature. I'm not sure if that changed after the patch or if I just didn't pay close enough attention to it when I applied the patch. (Probably the latter.)
···
On 3/12/10 9:44 AM, Cody Precord wrote:
Hi,
On Thu, Mar 11, 2010 at 11:11 PM, Robin Dunn<robin@alldunn.com> wrote:
There's a bug in the declaration of the Enable function in wxPyControl, so
when wx is calling it after the update ui event handler it is not passing
the call on to the everridden Enable in the generic button class.
I seem to remember writing a patch and creating a trac ticket for this
some time back to expose the wxWindow::Enable virtual method to python
subclasses. To fix an issue of calling Enable(False) on a Panel
wouldn't end up calling any overridden Enable methods in the child
controls of the Panel.