Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

tab help?

Help
2008-10-02
2013-05-01
  • Jeff Graver
    Jeff Graver
    2008-10-02

    I'm having trouble understanding how to use/change tabs in Boa.  Any tips?  Pointers to documentation?  Other?

    1) Whenever I open the "creation/tab order..." dialog, it is empty.  Except when I have selected a panel, in which case that panel is listed by itself.  Clicking "?" gets me a never-ending wait.

    2) I read in the wx docs that all windows have TAB_TRAVERSAL possibility, but when I set the "Catalog #" text box to TAB_TRAVERSAL = True, the tab key will not take me to the next item once I get to that text box

    3) On the other hand, if I set TAB_TRAVERSAL = True on the "Catalog #" _label_, tab never sets the focus on the label.

    4) After the "Customer" combo box, tab takes me somewhere that I don't want to go, but I can't figure out where.

    5) I would like to traverse all the text/choice/combo boxes before getting to the buttons.

    Thanks in advance

    Jeff

    Code Follows (sorry for length, but I didn't want to create a small test and fail to illustrate the problem):

    #Boa:Frame:OrderForm

    import wx

    def create(parent):
        return OrderForm(parent)

    [wxID_ORDERFORM, wxID_ORDERFORMADDBUTTON, wxID_ORDERFORMCANCELBUTTON,
    wxID_ORDERFORMCATALOGLABEL, wxID_ORDERFORMCATALOGNUMBER,
    wxID_ORDERFORMCOLORCHOICE, wxID_ORDERFORMCOLORLABEL, wxID_ORDERFORMCUSTOMER,
    wxID_ORDERFORMCUSTOMERLABEL, wxID_ORDERFORMDIOPTERCHOICE,
    wxID_ORDERFORMDIOPTERLABEL, wxID_ORDERFORMMATERIALCHOICE,
    wxID_ORDERFORMMATERIALLABEL, wxID_ORDERFORMORDERITEMS, wxID_ORDERFORMPANEL1,
    wxID_ORDERFORMPANEL2, wxID_ORDERFORMPOSTBUTTON, wxID_ORDERFORMQUANTITY,
    wxID_ORDERFORMQUANTITYLABEL, wxID_ORDERFORMSTYLECHOICE,
    wxID_ORDERFORMSTYLELABEL,
    ] = [wx.NewId() for _init_ctrls in range(21)]

    class OrderForm(wx.Frame):
        def _init_coll_CustModelBox_Items(self, parent):
            # generated method, don't edit

            parent.AddWindow(self.CustomerLabel, 0, border=0,
                  flag=wx.ALIGN_CENTER_VERTICAL)
            parent.AddWindow(self.Customer, 1, border=2, flag=wx.EXPAND | wx.ALL)

        def _init_coll_Traits_Items(self, parent):
            # generated method, don't edit

            parent.AddWindow(self.MaterialLabel, 0, border=0,
                  flag=wx.ALIGN_CENTER_VERTICAL)
            parent.AddWindow(self.MaterialChoice, 1, border=2,
                  flag=wx.ALL | wx.EXPAND)
            parent.AddWindow(self.ColorLabel, 0, border=0,
                  flag=wx.ALIGN_CENTER_VERTICAL)
            parent.AddWindow(self.ColorChoice, 1, border=2, flag=wx.EXPAND | wx.ALL)
            parent.AddWindow(self.StyleLabel, 0, border=0,
                  flag=wx.ALIGN_CENTER_VERTICAL)
            parent.AddWindow(self.StyleChoice, 1, border=2, flag=wx.EXPAND | wx.ALL)
            parent.AddWindow(self.DiopterLabel, 0, border=0,
                  flag=wx.ALIGN_CENTER_VERTICAL)
            parent.AddWindow(self.DiopterChoice, 1, border=2,
                  flag=wx.EXPAND | wx.ALL)

        def _init_coll_OrderBox_Items(self, parent):
            # generated method, don't edit

            parent.AddSizer(self.CustModelBox, 0, border=2, flag=wx.ALL)
            parent.AddSizer(self.DetailBox, 0, border=0, flag=0)
            parent.AddWindow(self.OrderItems, 1, border=0, flag=wx.EXPAND)

        def _init_coll_DetailBox_Items(self, parent):
            # generated method, don't edit

            parent.AddWindow(self.panel2, 0, border=3, flag=wx.ALL)
            parent.AddSizer(self.Traits, 0, border=2, flag=wx.ALL)

        def _init_coll_OrderItems_Columns(self, parent):
            # generated method, don't edit

            parent.InsertColumn(col=0, format=wx.LIST_FORMAT_LEFT,
                  heading='Catalog #', width=90)
            parent.InsertColumn(col=1, format=wx.LIST_FORMAT_LEFT,
                  heading='Description', width=-1)
            parent.InsertColumn(col=2, format=wx.LIST_FORMAT_LEFT,
                  heading='Quantity', width=90)

        def _init_sizers(self):
            # generated method, don't edit
            self.OrderBox = wx.BoxSizer(orient=wx.VERTICAL)

            self.CustModelBox = wx.BoxSizer(orient=wx.HORIZONTAL)

            self.DetailBox = wx.BoxSizer(orient=wx.HORIZONTAL)

            self.Traits = wx.FlexGridSizer(cols=2, hgap=0, rows=4, vgap=0)

            self._init_coll_OrderBox_Items(self.OrderBox)
            self._init_coll_CustModelBox_Items(self.CustModelBox)
            self._init_coll_DetailBox_Items(self.DetailBox)
            self._init_coll_Traits_Items(self.Traits)

            self.panel1.SetSizer(self.OrderBox)

        def _init_ctrls(self, prnt):
            # generated method, don't edit
            wx.Frame.__init__(self, id=wxID_ORDERFORM, name='OrderForm',
                  parent=prnt, pos=wx.Point(476, 305), size=wx.Size(419, 378),
                  style=wx.DEFAULT_FRAME_STYLE, title='Order Form')
            self.SetClientSize(wx.Size(411, 351))
            self.SetMinSize(wx.Size(419, 319))

            self.panel1 = wx.Panel(id=wxID_ORDERFORMPANEL1, name='panel1',
                  parent=self, pos=wx.Point(0, 0), size=wx.Size(411, 351),
                  style=wx.TAB_TRAVERSAL)

            self.CustomerLabel = wx.StaticText(id=wxID_ORDERFORMCUSTOMERLABEL,
                  label='Customer', name='CustomerLabel', parent=self.panel1,
                  pos=wx.Point(2, 8), size=wx.Size(47, 13), style=0)

            self.Customer = wx.ComboBox(choices=[], id=wxID_ORDERFORMCUSTOMER,
                  name='Customer', parent=self.panel1, pos=wx.Point(51, 4),
                  size=wx.Size(130, 21), style=0, value='')
            self.Customer.SetLabel('')

            self.OrderItems = wx.ListCtrl(id=wxID_ORDERFORMORDERITEMS,
                  name='OrderItems', parent=self.panel1, pos=wx.Point(0, 138),
                  size=wx.Size(411, 213), style=wx.LC_REPORT)
            self.OrderItems.SetLabel('Order Items')
            self._init_coll_OrderItems_Columns(self.OrderItems)

            self.panel2 = wx.Panel(id=wxID_ORDERFORMPANEL2, name='panel2',
                  parent=self.panel1, pos=wx.Point(3, 32), size=wx.Size(211, 103),
                  style=wx.TAB_TRAVERSAL)

            self.MaterialLabel = wx.StaticText(id=wxID_ORDERFORMMATERIALLABEL,
                  label='Material', name='MaterialLabel', parent=self.panel1,
                  pos=wx.Point(219, 37), size=wx.Size(55, 13), style=0)

            self.ColorLabel = wx.StaticText(id=wxID_ORDERFORMCOLORLABEL,
                  label='Color', name='ColorLabel', parent=self.panel1,
                  pos=wx.Point(219, 62), size=wx.Size(26, 13), style=0)

            self.StyleLabel = wx.StaticText(id=wxID_ORDERFORMSTYLELABEL,
                  label='Style', name='StyleLabel', parent=self.panel1,
                  pos=wx.Point(219, 87), size=wx.Size(25, 13), style=0)

            self.DiopterLabel = wx.StaticText(id=wxID_ORDERFORMDIOPTERLABEL,
                  label='Diopter', name='DiopterLabel', parent=self.panel1,
                  pos=wx.Point(219, 112), size=wx.Size(36, 13), style=0)

            self.MaterialChoice = wx.Choice(choices=[],
                  id=wxID_ORDERFORMMATERIALCHOICE, name='MaterialChoice',
                  parent=self.panel1, pos=wx.Point(276, 33), size=wx.Size(130, 21),
                  style=0)

            self.ColorChoice = wx.Choice(choices=[], id=wxID_ORDERFORMCOLORCHOICE,
                  name='ColorChoice', parent=self.panel1, pos=wx.Point(276, 58),
                  size=wx.Size(130, 21), style=0)

            self.StyleChoice = wx.Choice(choices=[], id=wxID_ORDERFORMSTYLECHOICE,
                  name='StyleChoice', parent=self.panel1, pos=wx.Point(276, 83),
                  size=wx.Size(130, 21), style=0)

            self.DiopterChoice = wx.Choice(choices=[],
                  id=wxID_ORDERFORMDIOPTERCHOICE, name='DiopterChoice',
                  parent=self.panel1, pos=wx.Point(276, 108), size=wx.Size(130, 21),
                  style=0)

            self.AddButton = wx.Button(id=wx.ID_ADD, label='', name='AddButton',
                  parent=self.panel2, pos=wx.Point(0, 80), size=wx.Size(64, 23),
                  style=0)

            self.PostButton = wx.Button(id=wx.ID_SAVE, label='', name='PostButton',
                  parent=self.panel2, pos=wx.Point(72, 80), size=wx.Size(64, 23),
                  style=0)

            self.CancelButton = wx.Button(id=wx.ID_CANCEL, label='',
                  name='CancelButton', parent=self.panel2, pos=wx.Point(144, 80),
                  size=wx.Size(67, 23), style=0)

            self.CatalogLabel = wx.StaticText(id=wxID_ORDERFORMCATALOGLABEL,
                  label='Catalog #', name='CatalogLabel', parent=self.panel2,
                  pos=wx.Point(0, 11), size=wx.Size(49, 16),
                  style=wx.TAB_TRAVERSAL)

            self.QuantityLabel = wx.StaticText(id=wxID_ORDERFORMQUANTITYLABEL,
                  label='Quantity', name='QuantityLabel', parent=self.panel2,
                  pos=wx.Point(0, 51), size=wx.Size(43, 16), style=0)

            self.CatalogNumber = wx.TextCtrl(id=wxID_ORDERFORMCATALOGNUMBER,
                  name='CatalogNumber', parent=self.panel2, pos=wx.Point(56, 8),
                  size=wx.Size(152, 21), style=wx.TAB_TRAVERSAL, value='')

            self.Quantity = wx.TextCtrl(id=wxID_ORDERFORMQUANTITY, name='Quantity',
                  parent=self.panel2, pos=wx.Point(56, 48), size=wx.Size(152, 21),
                  style=0, value='')

            self._init_sizers()

        def __init__(self, parent):
            self._init_ctrls(parent)

    if __name__ == '__main__':
        app = wx.PySimpleApp()
        frame = create(None)
        frame.Show()

        app.MainLoop()

     
    • Riaan Booysen
      Riaan Booysen
      2008-10-03

      Hi Jeff,

      The tab/creation order is set per container, like e.g. a panel.

      To change the order of the children in a panel, first select the panel, then right-click and select Creation/Tab Order...

      You should get the list of children which you can now move around.

      Cheers,
      Riaan.

       
    • Jeff Graver
      Jeff Graver
      2008-10-03

      OK, I see it now.  I must have had a serious brain freeze yesterday - still a newb and all.  I suppose this is why it is recommended that everything be put on panels.

      Time to redesign the form.

      Is there any reason to set/clear the TAB_TRAVERSAL property on controls that aren't simple containers?