[wxPython-users] Focus behavior change from 2.6 to 2.7?

Robin Dunn robin at alldunn.com
Fri Dec 1 17:01:00 PST 2006


Saketh wrote:

> 
> I have hacked together a small runnable sample which contains the 
> problem. Hit 'Tab' with the focus on the TreeCtrl and the problem 
> manifests itself.
> 
> I am on Windows XP SP2, wxPython 2.7.2.

It's not a problem.  It's doing exactly what you are telling it to do.

>         menubar = wx.MenuBar()
>         file = wx.Menu()
>         tab = file.Append(wx.NewId(), 'Insert Tab \tTab', 'Insert a tab')

Here you are crating a menu item with Tab as an accelerator...

>         menubar.Append(file, '&File')
>         self.SetMenuBar(menubar)
>         self.Bind(wx.EVT_MENU, self.OnTab, tab)

...and you are binding that menu event to the OnTab method...

>     def OnTab(self, e):
>         self.display.WriteText(unicode('\t'))

...which writes a tab character to the text control.  So whenever you 
press Tab while any control within the frame has the focus it is going 
to activate the accelerator and call OnTab.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list