[wxPython] How to change deafult tab traversing (radiobuttons & panel)

w.p. ptaku2_wywal_to_ at tlen.pl
Tue Jun 7 00:22:14 CEST 2005


Hello!

I want change default tab traversing in my app. But i don't know how to do it :(

Belowe i include simple example - i want change default tab order:

radiobutton "mode11" -> radiobutton "mode31" -> button OK

I can't find any option, flag, or another way.

I try use wx.EVT_KEY_DOWN macro, or Bind - but without success.


When i use Borland Builder C++ i must only set tabStop=False ....

sorry for my english !

w.p.

#######################################################################################
import wx

class MyFrame(wx.Frame):
     def __init__(self, parent, title):
         wx.Frame.__init__(self, parent, -1, title)

         mainPanel = wx.Panel(self)
         mainSizer = wx.BoxSizer(wx.VERTICAL)

         panel1=wx.Panel(mainPanel,style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER,size=(200,100))
         mainSizer.Add(panel1,flag=wx.ALL,border=5)

         panel2=wx.Panel(mainPanel,style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER,size=(200,100))
         mainSizer.Add(panel2,flag=wx.ALL,border=5)

         # group 1
         gridSiz1 = wx.FlexGridSizer(2,2)
         panel1.SetSizer(gridSiz1)

         self.rb11 = wx.RadioButton(panel1, -1, style=wx.RB_GROUP, label="mode 11")
         self.rb12 = wx.RadioButton(panel1, -1, label="mode 12")
         self.rb21 = wx.RadioButton(panel1, -1, style=wx.RB_GROUP, label="mode 21")
         self.rb22 = wx.RadioButton(panel1, -1, label="mode 22")

         gridSiz1.Add(self.rb11,flag=wx.ALL,border=3)
         gridSiz1.Add(self.rb12,flag=wx.ALL,border=3)
         gridSiz1.Add(self.rb21,flag=wx.ALL,border=3)
         gridSiz1.Add(self.rb22,flag=wx.ALL,border=3)

         # group 2
         gridSiz2 = wx.FlexGridSizer(2,2)
         panel2.SetSizer(gridSiz2)

         self.rb31 = wx.RadioButton(panel2, -1, style=wx.RB_GROUP, label="mode 31")
         self.rb32 = wx.RadioButton(panel2, -1, label="mode 32")
         self.rb41 = wx.RadioButton(panel2, -1, style=wx.RB_GROUP, label="mode 41")
         self.rb42 = wx.RadioButton(panel2, -1, label="mode 42")

         gridSiz2.Add(self.rb31,flag=wx.ALL,border=3)
         gridSiz2.Add(self.rb32,flag=wx.ALL,border=3)
         gridSiz2.Add(self.rb41,flag=wx.ALL,border=3)
         gridSiz2.Add(self.rb42,flag=wx.ALL,border=3)

         okBut = wx.Button(mainPanel,label="-- OK --")
         mainSizer.Add(okBut,flag=wx.ALL|wx.ALIGN_CENTER,border=10)

         mainPanel.SetSizer(mainSizer)
         self.Layout()

#        wx.EVT_KEY_DOWN(self.rb11,self.OnRBKD)
         self.rb11.Bind(wx.EVT_KEY_DOWN, self.OnRBKD)


     def OnRBKD(self,event):
          print "OnKey!"
          event.Skip()


class MyApp(wx.App):
     def OnInit(self):
         frame = MyFrame(None, "Simple wxPython App")
         self.SetTopWindow(frame)
         frame.Show(True)
         return True

app = MyApp(0)
app.MainLoop()




More information about the Python-list mailing list