That should work. I was able to make it work with the
show functionality for each widget. I will move them
inside their own panel and try to use show or Enable on
the entire panel. Thanks. It is so much fun when things
work!!!
--vicki
What about putting the sizer in question inside a
panel
(say
self.panel1) and make each widget a child of the
panel?
Then:
for widget in self.panel1.GetChildren():
widget.Enable(False)
or
for widget in self.panel1.GetChildren():
widget.Enable(True)
I've been looking through the api and trying to find the trick to setting the attributes on a disabled widget. Can someone please show me the way?
There is no way to do it. The various platforms (or even various themes on the same platform) all have their own interpretation of what it means to be disabled, and some of them don't allow changing the attributes on native controls even when they are enabled.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I've been looking through the api and trying to find the trick to setting the attributes on a disabled widget. Can someone please show me the way?
There is no way to do it. The various platforms (or even various themes on the same platform) all have their own interpretation of what it means to be disabled, and some of them don't allow changing the attributes on native controls even when they are enabled.
That's what I discovered too -- and I had a requirement to do exactly this in one of my programs. To get around it, I created my disabled text widget as a subclass of wxStaticText instead of wxTextCtrl. Mind you, I only needed to have the text drawn in black rather than in gray -- if you need proper colouring, you might need to write your own custom wxWindow subclass which does the drawing for you (I'm not sure if wxStaticText supports different font colouring).
One other possibility: you could probably override the OnPaint handler for wxTextCtrl and replace the drawing logic for a disabled text control with your own code. Take a look at wxPython.lib.rightalign for an example of how to override the display of text in a wxTextCtrl. I used this technique to have a wxTextCtrl which draws the field's label inside the text control when the field has no value -- this works well, and saves lots of screen space when you've got lots of fields to display in a limited-size window.
One other possibility: you could probably override the OnPaint handler for wxTextCtrl and replace the drawing logic for a disabled text control with your own code. Take a look at wxPython.lib.rightalign for an example of how to override the display of text in a wxTextCtrl. I used this technique to have a wxTextCtrl which draws the field's label inside the text control when the field has no value -- this works well, and saves lots of screen space when you've got lots of fields to display in a limited-size window.
This will work on MSW, but it won't on the other platforms.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
One other possibility: you could probably override the OnPaint handler for wxTextCtrl and replace the drawing logic for a disabled text control with your own code. Take a look at wxPython.lib.rightalign for an example of how to override the display of text in a wxTextCtrl. I used this technique to have a wxTextCtrl which draws the field's label inside the text control when the field has no value -- this works well, and saves lots of screen space when you've got lots of fields to display in a limited-size window.
This will work on MSW, but it won't on the other platforms.
So wxPython.lib.rightalign only works under MSW??? I copied the code/logic directly from that module...
One other possibility: you could probably override the OnPaint handler for wxTextCtrl and replace the drawing logic for a disabled text control with your own code. Take a look at wxPython.lib.rightalign for an example of how to override the display of text in a wxTextCtrl. I used this technique to have a wxTextCtrl which draws the field's label inside the text control when the field has no value -- this works well, and saves lots of screen space when you've got lots of fields to display in a limited-size window.
This will work on MSW, but it won't on the other platforms.
So wxPython.lib.rightalign only works under MSW??? I copied the code/logic directly from that module...
Unfortunately, yes. wxWindows is not able to guarantee that all events are generated the same way on all platforms for all native widgets, especially the low level events like EVT_PAINT.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
So wxPython.lib.rightalign only works under MSW??? I copied the code/logic directly from that module...
Unfortunately, yes. wxWindows is not able to guarantee that all events are generated the same way on all platforms for all native widgets, especially the low level events like EVT_PAINT.
I'm almost afraid to ask...does this mean it won't work under wxMAC? I've got a firm requirement for this functionality, and have committed to getting our existing program running on OSX -- if this doesn't work I may have to completely reimplement wxTextCtrl in Python if I can't get it working in some other way. My boss is going to be fuming if I can't get this going...
So wxPython.lib.rightalign only works under MSW??? I copied the code/logic directly from that module...
Unfortunately, yes. wxWindows is not able to guarantee that all events are generated the same way on all platforms for all native widgets, especially the low level events like EVT_PAINT.
I'm almost afraid to ask...does this mean it won't work under wxMAC? I've got a firm requirement for this functionality, and have committed to getting our existing program running on OSX -- if this doesn't work I may have to completely reimplement wxTextCtrl in Python if I can't get it working in some other way. My boss is going to be fuming if I can't get this going...
It almost works, and could probably be made to work better with a little pounding. I'm hoping though to get the wxTE_RIGHT style flag supported in wxMac, as that would be the best solution.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!