[wxPython-users] Focus on an non focusable window

Jorgen Bodde jorgen.maillist at gmail.com
Tue Nov 6 04:07:13 PST 2007


Hi Robin,

It seems the wx.Panel does get the focus because I added a
EVT_GET_FOCUS and colored the background red, and the panel
responsible got red. The panel had no other controls, only a custom
evt_paint.

Thanks for the tip about using wx.PyPanel I will see if that prevents
the panel from stealing the focus..

Regards,
- Jorgen

On 11/5/07, Robin Dunn <robin at alldunn.com> wrote:
> Jorgen Bodde wrote:
> > Hi Guys,
> >
> > I'm writing some kind of property sheet and I noticed that tabbing
> > from a wx.TextCtrl to another wx.TextCtrl (which are the only two
> > focusable elements on my wx.Frame) leaves a gap in the focusing.
> >
> > This is what happens;
> >
> > Focus on wx.TextCtrl  -> TAB
> > Focus on something invisible -> TAB
> > Focus on wx.TextCtrl
> > Focus on something invisible -> TAB
> > etc.
> >
> > This is consistent on wxGTK and wxMSW, I did derive a wx.Panel to get
> > a custom text and better click abilities, but AFAIK a wx.Panel should
> > not steal the focus.
> >
> > I read something about a derived method AcceptsFocus and
> > AcceptsFocusFromKeyboard where you can return False to avoid focussing
> > but this does not seem to help.
>
>
> You need to derive from wx.PyPanel for these C++ virtual method calls to
> be reflected to the Python method, but as you guessed the default
> behavior for a panel is to not take the focus if it has a child it can
> pass it on to instead.
>
> >
> > Are there any other elements in wxWidgets that can have focus but have
> > no input? So far I used only wx.Panel, and a spacer in my sizer, but
> > nothing else actually.
>
> Try making a timer whose handler prints the value of
> wx.Window.FindFocus() and see what it prints when your focus is not
> where you expect it to be.
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org  Java give you jitters?  Relax with wxPython!
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>




More information about the wxpython-users mailing list