I have a dialog, and I’ve explored all the “stations” in its tab traversal order, and discovered that one station (which happens to be the first station that focus is on when you open the dialog) is null. No accelerators work when the focus is on this “station,” and when I debug and do dialog.FindFocus() I get None in return.
What is this? Is this a known phenomenon? Am I doing something wrong? And how can I stop this?
Update: Focus was actually not null, but it was on some custom widget. But a problem still remains: When focus is on the custom widget, I can’t do Alt-H to trigger the accelerator in a StaticText in the same dialog. I can’t do this on Windows XP, but on Ubuntu it works. Why? How can this be fixed?
What is the custom widget? Is it doing anything with the key events that could block accelerators? As always, a small runnable sample would help us answer your questions. MakingSampleApps - wxPyWiki
···
On 6/1/11 2:45 AM, cool-RR wrote:
Update: Focus was actually not null, but it was on some custom widget.
But a problem still remains: When focus is on the custom widget, I can't
do Alt-H to trigger the accelerator in a `StaticText` in the same
dialog. I can't do this on Windows XP, but on Ubuntu it works. Why? How
can this be fixed?
Update: Focus was actually not null, but it was on some custom widget.
But a problem still remains: When focus is on the custom widget, I can’t
do Alt-H to trigger the accelerator in a StaticText in the same
dialog. I can’t do this on Windows XP, but on Ubuntu it works. Why? How
can this be fixed?
What is the custom widget? Is it doing anything with the key events that could block accelerators? As always, a small runnable sample would help us answer your questions. http://wiki.wxpython.org/MakingSampleApps
If the Comparer widget does not need to have the focus itself then you can work around this by using wx.PyPanel as its base class and returning False from an overridden AcceptsFocus method. If it does need to have the focus then try using wx.PyControl as the base class. I tried using a wx.lib.buttons.GenButton in place of your Comparer widget in the sample and the accelerator does work in that case.
···
On 6/1/11 1:10 PM, cool-RR wrote:
On Wed, Jun 1, 2011 at 1:21 PM, Robin Dunn <robin@alldunn.com > <mailto:robin@alldunn.com>> wrote:
On 6/1/11 2:45 AM, cool-RR wrote:
Update: Focus was actually not null, but it was on some custom
widget.
But a problem still remains: When focus is on the custom widget,
I can't
do Alt-H to trigger the accelerator in a `StaticText` in the same
dialog. I can't do this on Windows XP, but on Ubuntu it works.
Why? How
can this be fixed?
What is the custom widget? Is it doing anything with the key events
that could block accelerators? As always, a small runnable sample
would help us answer your questions. MakingSampleApps - wxPyWiki
What is the custom widget? Is it doing anything with the key events
that could block accelerators? As always, a small runnable sample
would help us answer your questions.
[http://wiki.wxpython.org/MakingSampleApps](http://wiki.wxpython.org/MakingSampleApps)
--
Robin Dunn
Put the focus on the (now invisible) Comparer widget and press Alt-H.
It won’t go to the accelerator. (I tested this on XP.)
If the Comparer widget does not need to have the focus itself then you can work around this by using wx.PyPanel as its base class and returning False from an overridden AcceptsFocus method. If it does need to have the focus then try using wx.PyControl as the base class. I tried using a wx.lib.buttons.GenButton in place of your Comparer widget in the sample and the accelerator does work in that case.
–
Robin Dunn
The widget does need to get focus, so I tried using wx.PyControl as a base class but the accelerator is still not working when focus is on the Comparer.
Ah, I have tried using wx.PyControl as a second base class in addition to wx.Panel and it didn’t work. Now I removed wx.Panel and used wx.PyControl exclusively (including calling wx.PyControl.__init__) and it does work. But is this good? I mean, I’m used to working with panels and windows, what’s the logic in changing to a PyControl? Is there a wxPython bug here?
What is the custom widget? Is it doing anything with the key events
that could block accelerators? As always, a small runnable sample
would help us answer your questions.
[http://wiki.wxpython.org/MakingSampleApps](http://wiki.wxpython.org/MakingSampleApps)
--
Robin Dunn
Put the focus on the (now invisible) Comparer widget and press Alt-H.
It won’t go to the accelerator. (I tested this on XP.)
If the Comparer widget does not need to have the focus itself then you can work around this by using wx.PyPanel as its base class and returning False from an overridden AcceptsFocus method. If it does need to have the focus then try using wx.PyControl as the base class. I tried using a wx.lib.buttons.GenButton in place of your Comparer widget in the sample and the accelerator does work in that case.
–
Robin Dunn
The widget does need to get focus, so I tried using wx.PyControl as a base class but the accelerator is still not working when focus is on the Comparer.
What is the custom widget? Is it doing anything with
the key events
that could block accelerators? As always, a small
runnable sample
would help us answer your questions. MakingSampleApps - wxPyWiki
Put the focus on the (now invisible) `Comparer` widget and
press Alt-H.
It won't go to the accelerator. (I tested this on XP.)
If the Comparer widget does not need to have the focus itself
then you can work around this by using wx.PyPanel as its base
class and returning False from an overridden AcceptsFocus
method. If it does need to have the focus then try using
wx.PyControl as the base class. I tried using a
wx.lib.buttons.GenButton in place of your Comparer widget in the
sample and the accelerator does work in that case.
--
Robin Dunn
The widget does need to get focus, so I tried using `wx.PyControl`
as a base class but the accelerator is still not working when focus
is on the `Comparer`.
Ram.
Ah, I have tried using `wx.PyControl` as a second base class in addition
to `wx.Panel` and it didn't work.
You definitely should not use multiple inheritance with more than on UI class. It might not cause a tear in the space-time continuum, but it is probably close.
Now I removed `wx.Panel` and
used `wx.PyControl` exclusively (including
calling `wx.PyControl.__init__`) and it does work. But is this good? I
mean, I'm used to working with panels and windows, what's the logic in
changing to a `PyControl`?
wxControl is the base class for most UI objects that are meant interact with the user (other than the static controls,) possibly be a tab-stop, and to not contain other widgets. Other than that it is just like any other wx.Window.
Is there a wxPython bug here?
No.
···
On 6/2/11 12:28 PM, cool-RR wrote:
On Thu, Jun 2, 2011 at 9:24 PM, cool-RR <cool-rr@cool-rr.com > <mailto:cool-rr@cool-rr.com>> wrote:
What is the custom widget? Is it doing anything with
the key events
that could block accelerators? As always, a small
runnable sample
would help us answer your questions.
[http://wiki.wxpython.org/MakingSampleApps](http://wiki.wxpython.org/MakingSampleApps)
--
Robin Dunn
Here, I reduced it to a sample:
[https://github.com/cool-RR/GarlicSim/raw/sample/garlicsim_wx/garlicsim_wx/widgets/general_misc/hue_selection_dialog/hue_selection_dialog.py](https://github.com/cool-RR/GarlicSim/raw/sample/garlicsim_wx/garlicsim_wx/widgets/general_misc/hue_selection_dialog/hue_selection_dialog.py)
Put the focus on the (now invisible) `Comparer` widget and
press Alt-H.
It won't go to the accelerator. (I tested this on XP.)
If the Comparer widget does not need to have the focus itself
then you can work around this by using wx.PyPanel as its base
class and returning False from an overridden AcceptsFocus
method. If it does need to have the focus then try using
wx.PyControl as the base class. I tried using a
wx.lib.buttons.GenButton in place of your Comparer widget in the
sample and the accelerator does work in that case.
--
Robin Dunn
The widget does need to get focus, so I tried using `wx.PyControl`
as a base class but the accelerator is still not working when focus
is on the `Comparer`.
Ram.
Ah, I have tried using wx.PyControl as a second base class in addition
to wx.Panel and it didn’t work.
You definitely should not use multiple inheritance with more than on UI class. It might not cause a tear in the space-time continuum, but it is probably close.
Now I removed wx.Panel and
used wx.PyControl exclusively (including
calling wx.PyControl.__init__) and it does work. But is this good? I
mean, I’m used to working with panels and windows, what’s the logic in
changing to a PyControl?
wxControl is the base class for most UI objects that are meant interact with the user (other than the static controls,) possibly be a tab-stop, and to not contain other widgets. Other than that it is just like any other wx.Window.
Good to know! From now on I’ll use wx.Control as a base class for all of my non-container widgets.
calling wx.PyControl.__init__) and it does work. But is this good? I
mean, I’m used to working with panels and windows, what’s the logic in
changing to a PyControl?
wxControl is the base class for most UI objects that are meant interact with the user (other than the static controls,) possibly be a tab-stop, and to not contain other widgets. Other than that it is just like any other wx.Window.
Good to know! From now on I’ll use wx.Control as a base class for all of my non-container widgets.
Ram.
Robin, the wx.Control suggestion worked on my sample, but not on my app. This helped me find the real cause of the problem: The wx.TAB_TRAVERSAL style. When it’s removed, the accelerator works regardless if it’s a Panel or a Control.
Now the questions are:
Why is wx.TAB_TRAVERSAL preventing me from using accelerators?
Do I need the wx.TAB_TRAVERSAL flag? I googled for some documentation about it but it was pretty scarce. I removed it and I’m still able to use tab traversal in the dialog, but of course I can’t know whether it affects something I haven’t checked or under a different OS.
More generally, if wx.Control doesn’t help here, is there any way in which it is better than wx.Panel for non-container widgets?