tabbing between panels

Greetings,
I am looking a for a keystroke technique that will allow my users to 'Jump' between scrolled panels (like a short cut key or something), which are on the same parent panel.

Could I map 'F1' or 'F2' to do that? How?

Currently they will have to tab through an the entire list to change panels (unless they use the mouse).

Any suggestions?

Scott

···

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005

Ok, I figure part of it out, but now I can't get the focus to switch back. It appears to work only once...

I'm going for a 'ping - pong' kinda thing.

Here is my code:

self.Bind(wx.EVT_CHAR_HOOK, self._onChar)
...

def _onChar(self, event):
         keycode = event.GetKeyCode()
         #print keycode
         #print self.p.pnl1.panel1.FindFocus()

         if keycode == wx.WXK_F2:
             if self.p.pnl1.panel1.FindFocus():
                 self.p.pnl1.panel2.SetFocus()

             elif self.p.pnl1.panel2.FindFocus():
                 self.p.pnl1.panel1.SetFocus()
             else:
                 pass
         event.Skip()

Is there another or better way?

Thanks
Scott

scott wrote:

···

Greetings,
I am looking a for a keystroke technique that will allow my users to 'Jump' between scrolled panels (like a short cut key or something), which are on the same parent panel.

Could I map 'F1' or 'F2' to do that? How?

Currently they will have to tab through an the entire list to change panels (unless they use the mouse).

Any suggestions?

Scott

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005

scott wrote:

Ok, I figure part of it out, but now I can't get the focus to switch back. It appears to work only once...

I'm going for a 'ping - pong' kinda thing.

Here is my code:

self.Bind(wx.EVT_CHAR_HOOK, self._onChar)
...

def _onChar(self, event):
        keycode = event.GetKeyCode()
        #print keycode
        #print self.p.pnl1.panel1.FindFocus()

        if keycode == wx.WXK_F2:
            if self.p.pnl1.panel1.FindFocus():
                self.p.pnl1.panel2.SetFocus()

            elif self.p.pnl1.panel2.FindFocus():
                self.p.pnl1.panel1.SetFocus()
            else:
                pass
        event.Skip()

Is there another or better way?

FindFocus is a staticmethod and so your intended use is incorrect. It will always return the widget with the focus no matter where it is in the app. One way you could do what you want is to get the widget with the focus and then travel up its parent chain until you find panel1 or panel2

Could I map 'F1' or 'F2' to do that? How?

I think that Ctrl-Tab is usually used for this type of thing, and there may already be a EVT_NAVIGATION_KEY event generated for it. If so then you can check event.IsWindowChange to know if you should chagne panels or just Skip() the event for normal tab traversal.

···

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