problem with tab order using wx.CheckBox

I am having issues with the tab order in the following code. This snippet creates a frame, puts a panel in the frame, places a checkbox followed by a textctrl; tabbing from the checkbox goes into the textctl as expected. Then I start nesting things onto the main panel: a child panel, on which i place a checkbox followed by a textctl. On these subpanels, when I place the focus on the checkbox and press tab, the focus goes NOT to the textctrl but to the next checkbox on the next panel, skipping the textctrl. What am I doing wrong here?

Thanks for any advice,
Hank

import wx

class TestApp(wx.PySimpleApp):

···

#---
    def MakeFrame(self):
        self.frame=wx.Frame(None,-1,'Testing InputWidgets',size=(750,500))
        self.frame.CreateStatusBar()
        self.panel=wx.Panel(self.frame,-1)
        self.panel.SetBackgroundColour('yellow')
        mainSizer=wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(mainSizer)
        mainSizer.Add(wx.CheckBox(self.panel,-1,'click'))
        mainSizer.Add(wx.TextCtrl(self.panel,-1,value='bic'),0,wx.ALL|wx.EXPAND,6)
        #--- layout test widgets
        colours=['pink','wheat','blue','green','white']
        for i in range(2):
            panel=wx.Panel(self.panel,-1,style=wx.SIMPLE_BORDER)
            szr=wx.BoxSizer(wx.VERTICAL)
            panel.SetSizer(szr)
            szr.Add(wx.CheckBox(panel,-1,'click'))
            szr.Add(wx.TextCtrl(panel,-1),0,wx.ALL|wx.EXPAND,6)
            mainSizer.Add(panel,0,wx.EXPAND|wx.ALL,4)
            panel.SetBackgroundColour(colours[i%len(colours)])
        self.frame.Show()
    #---
    def OnInit(self):
        self.MakeFrame()
        return True

    def OnClose(self,evt):
        self.frame.Destroy()
#---
app=TestApp(redirect=False)
app.MainLoop()

I did some more tinkering with my snippet. No matter how many or what kind of widgets I add to the nested panel, pressing TAB from any of them causes focus to go to the first widget on the next panel.
Hank

Hank Knox wrote:

···

I am having issues with the tab order in the following code. This snippet creates a frame, puts a panel in the frame, places a checkbox followed by a textctrl; tabbing from the checkbox goes into the textctl as expected. Then I start nesting things onto the main panel: a child panel, on which i place a checkbox followed by a textctl. On these subpanels, when I place the focus on the checkbox and press tab, the focus goes NOT to the textctrl but to the next checkbox on the next panel, skipping the textctrl. What am I doing wrong here?

Thanks for any advice,
Hank

import wx

class TestApp(wx.PySimpleApp):
   #---
   def MakeFrame(self):
       self.frame=wx.Frame(None,-1,'Testing InputWidgets',size=(750,500))
       self.frame.CreateStatusBar()
       self.panel=wx.Panel(self.frame,-1)
       self.panel.SetBackgroundColour('yellow')
       mainSizer=wx.BoxSizer(wx.VERTICAL)
       self.panel.SetSizer(mainSizer)
       mainSizer.Add(wx.CheckBox(self.panel,-1,'click'))
       mainSizer.Add(wx.TextCtrl(self.panel,-1,value='bic'),0,wx.ALL|wx.EXPAND,6)

       #--- layout test widgets
       colours=['pink','wheat','blue','green','white']
       for i in range(2):
           panel=wx.Panel(self.panel,-1,style=wx.SIMPLE_BORDER)
           szr=wx.BoxSizer(wx.VERTICAL)
           panel.SetSizer(szr)
           szr.Add(wx.CheckBox(panel,-1,'click'))
           szr.Add(wx.TextCtrl(panel,-1),0,wx.ALL|wx.EXPAND,6)
           mainSizer.Add(panel,0,wx.EXPAND|wx.ALL,4)
           panel.SetBackgroundColour(colours[i%len(colours)])
       self.frame.Show()
   #---
   def OnInit(self):
       self.MakeFrame()
       return True

   def OnClose(self,evt):
       self.frame.Destroy()
#---
app=TestApp(redirect=False)
app.MainLoop()

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

The default tab order is the creation order of the widgets. In your
case the simplest solution is to create the text control before the
checkbox.

···

On 1/25/07, Hank Knox <hank@music.mcgill.ca> wrote:

I am having issues with the tab order in the following code. This
snippet creates a frame, puts a panel in the frame, places a checkbox
followed by a textctrl; tabbing from the checkbox goes into the textctl
as expected. Then I start nesting things onto the main panel: a child
panel, on which i place a checkbox followed by a textctl. On these
subpanels, when I place the focus on the checkbox and press tab, the
focus goes NOT to the textctrl but to the next checkbox on the next
panel, skipping the textctrl. What am I doing wrong here?

Thanks for any advice,
Hank

import wx

class TestApp(wx.PySimpleApp):
    #---
    def MakeFrame(self):
        self.frame=wx.Frame(None,-1,'Testing InputWidgets',size=(750,500))
        self.frame.CreateStatusBar()
        self.panel=wx.Panel(self.frame,-1)
        self.panel.SetBackgroundColour('yellow')
        mainSizer=wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(mainSizer)
        mainSizer.Add(wx.CheckBox(self.panel,-1,'click'))

mainSizer.Add(wx.TextCtrl(self.panel,-1,value='bic'),0,wx.ALL|wx.EXPAND,6)
        #--- layout test widgets
        colours=['pink','wheat','blue','green','white']
        for i in range(2):
            panel=wx.Panel(self.panel,-1,style=wx.SIMPLE_BORDER)
            szr=wx.BoxSizer(wx.VERTICAL)
            panel.SetSizer(szr)
            szr.Add(wx.CheckBox(panel,-1,'click'))
            szr.Add(wx.TextCtrl(panel,-1),0,wx.ALL|wx.EXPAND,6)
            mainSizer.Add(panel,0,wx.EXPAND|wx.ALL,4)
            panel.SetBackgroundColour(colours[i%len(colours)])
        self.frame.Show()
    #---
    def OnInit(self):
        self.MakeFrame()
        return True

    def OnClose(self,evt):
        self.frame.Destroy()
#---
app=TestApp(redirect=False)
app.MainLoop()

I must be missing something. Inside the for loop, if the create the text control first and enter the text control, pressing tab still takes me from the text control in the first nested panel to the first control on the next PANEL, not the next control on the same panel even though it was created immediately after the first control.
Hank

Chris Mellon wrote:

···

On 1/25/07, Hank Knox <hank@music.mcgill.ca> wrote:

I am having issues with the tab order in the following code. This
snippet creates a frame, puts a panel in the frame, places a checkbox
followed by a textctrl; tabbing from the checkbox goes into the textctl
as expected. Then I start nesting things onto the main panel: a child
panel, on which i place a checkbox followed by a textctl. On these
subpanels, when I place the focus on the checkbox and press tab, the
focus goes NOT to the textctrl but to the next checkbox on the next
panel, skipping the textctrl. What am I doing wrong here?

Thanks for any advice,
Hank

import wx

class TestApp(wx.PySimpleApp):
    #---
    def MakeFrame(self):
        self.frame=wx.Frame(None,-1,'Testing InputWidgets',size=(750,500))
        self.frame.CreateStatusBar()
        self.panel=wx.Panel(self.frame,-1)
        self.panel.SetBackgroundColour('yellow')
        mainSizer=wx.BoxSizer(wx.VERTICAL)
        self.panel.SetSizer(mainSizer)
        mainSizer.Add(wx.CheckBox(self.panel,-1,'click'))

mainSizer.Add(wx.TextCtrl(self.panel,-1,value='bic'),0,wx.ALL|wx.EXPAND,6)

        #--- layout test widgets
        colours=['pink','wheat','blue','green','white']
        for i in range(2):
            panel=wx.Panel(self.panel,-1,style=wx.SIMPLE_BORDER)
            szr=wx.BoxSizer(wx.VERTICAL)
            panel.SetSizer(szr)
            szr.Add(wx.CheckBox(panel,-1,'click'))
            szr.Add(wx.TextCtrl(panel,-1),0,wx.ALL|wx.EXPAND,6)
            mainSizer.Add(panel,0,wx.EXPAND|wx.ALL,4)
            panel.SetBackgroundColour(colours[i%len(colours)])
        self.frame.Show()
    #---
    def OnInit(self):
        self.MakeFrame()
        return True

    def OnClose(self,evt):
        self.frame.Destroy()
#---
app=TestApp(redirect=False)
app.MainLoop()

The default tab order is the creation order of the widgets. In your
case the simplest solution is to create the text control before the
checkbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

I misread your code when I first replied. This is definitely a bug.
Note that reverse-tabbing works correctly. Calling Navigate() on one
of the nested checkboxes correctly goes to the text control, so whats
probably happening is that the top level panel is catching the
navigation event, instead of being correctly handled by the nested
panel. Please file a bug report about this on Sourceforge.

···

On 1/25/07, Hank Knox <hank@music.mcgill.ca> wrote:

I must be missing something. Inside the for loop, if the create the text
control first and enter the text control, pressing tab still takes me
from the text control in the first nested panel to the first control on
the next PANEL, not the next control on the same panel even though it
was created immediately after the first control.
Hank

Woops, spoke to soon (again). You need to add the wx.TAB_TRAVERSAL
style to your embedded panels and then everything will work fine. This
is actually correct and expected behavior, I just missed that you
weren't using the default style.

···

On 1/25/07, Chris Mellon <arkanes@gmail.com> wrote:

On 1/25/07, Hank Knox <hank@music.mcgill.ca> wrote:
> I must be missing something. Inside the for loop, if the create the text
> control first and enter the text control, pressing tab still takes me
> from the text control in the first nested panel to the first control on
> the next PANEL, not the next control on the same panel even though it
> was created immediately after the first control.
> Hank
>

I misread your code when I first replied. This is definitely a bug.
Note that reverse-tabbing works correctly. Calling Navigate() on one
of the nested checkboxes correctly goes to the text control, so whats
probably happening is that the top level panel is catching the
navigation event, instead of being correctly handled by the nested
panel. Please file a bug report about this on Sourceforge.

Chris,

MANY thanks, that solves it. Your fast response is much appreciated.

Hank

Chris Mellon wrote:

···

On 1/25/07, Chris Mellon <arkanes@gmail.com> wrote:

On 1/25/07, Hank Knox <hank@music.mcgill.ca> wrote:
> I must be missing something. Inside the for loop, if the create the text
> control first and enter the text control, pressing tab still takes me
> from the text control in the first nested panel to the first control on
> the next PANEL, not the next control on the same panel even though it
> was created immediately after the first control.
> Hank
>

I misread your code when I first replied. This is definitely a bug.
Note that reverse-tabbing works correctly. Calling Navigate() on one
of the nested checkboxes correctly goes to the text control, so whats
probably happening is that the top level panel is catching the
navigation event, instead of being correctly handled by the nested
panel. Please file a bug report about this on Sourceforge.

Woops, spoke to soon (again). You need to add the wx.TAB_TRAVERSAL
style to your embedded panels and then everything will work fine. This
is actually correct and expected behavior, I just missed that you
weren't using the default style.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org