ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> wxPython-users
wxPython-users
Re: [wxPython-users] Notebook pages not receiving focus
by geoff catlin other posts by this author
Dec 10 2004 5:36AM messages near this date
Re: [wxPython-users] Problem in opening a file from open dialog | Re: [wxPython-users] Notebook pages not receiving focus
Thanks for the reply Robin! Responses below:


Robin Dunn wrote:

>  geoff catlin wrote:
> 
> > I'm working on a slightly modified Notebook control and I'm having 
> > trouble getting notebook pages to receive focus when clicking on the 
> > tabs or doing CTRL+TAB on the keyboard. I put a fairly minimal 
> > example up at: http://pyroscope.org/notebook.py
> >
> > It works fine when adding or deleting pages but the function handling 
> > EVT_NOTEBOOK_PAGE_CHANGED events (OnPageChanged) does not appear to 
> > be having an effect. What am I doing wrong?
> 
>  Probably the notebook is resetting focus to itself after the event 
>  handler has completed.  To work around this you can use wx.CallAfter 
>  to do it after all pending events and such have been processed, like 
>  this:
> 
>      def OnPageChanged(self, event):
>          print "OPC:", event.GetSelection()
>          wx.CallAfter(self.DoSetFocus, event.GetSelection())
>          event.Skip(True)
> 
>      def DoSetFocus(self, sel):
>          print "DSF: ", sel
>          self.GetPage(sel).SetFocus()

wx.CallAfter worked nicely. I bet that'll come in handy in the future, too.


> > On a related note, is it possibly to modify the CTRL+TAB behavior to 
> > cycle through pages in most-recently-selected order instead of in 
> > order of creation?
> 
>  No.

It's not that I don't believe you, but that wasn't the answer I wanted 
to hear, so I figured out a way to do it. :)

Of course, this may be a problem-specific hack, but, by extending the 
AddPage and InsertPage methods to bind EVT_KEY_UP and EVT_KEY_DOWN 
handler methods to all new pages, the Notebook can watch for Cmd 
keystrokes, intercept NavigationKey events, and decide which page to 
show. This probably only works because the pages that I'm adding consist 
of a single Control, but I'm guessing that Notebooks are often used 
liked that. FWIW, I also got tab dragging/re-ordering working.

I posted an example at: http://pyroscope.org/notebook2.py

If anyone cares to look at it, please let me know if there are any 
improvements I can make to the code.

Thanks!

-geoff


---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@[...].org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org
Thread:
geoff catlin
Robin Dunn

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved