简体   繁体   中英

WxPython switch between controls using tab button

I have a window contains different kinds of controls.

class FindReplaceWindow(wx.MiniFrame):
  def __init__(self, parent):
    Style = wx.DEFAULT_MINIFRAME_STYLE|wx.SYSTEM_MENU|wx.CLOSE_BOX
    super(FindReplaceWindow, self).__init__(parent, -1, 'Find and Replace', style = Style)
    self.BackgroundColour = wx.WHITE
    self.MaxSize = wx.Size(400,300)
    self.MinSize = self.MaxSize
    self.CenterOnParent()
    self.LabelFind = wx.StaticText(self, label = 'Find')
    self.LabelReplace = wx.StaticText(self, label = 'Replace')
    self.LabelTransparency = wx.StaticText(self, label = 'Transparency')
    self.TextFind = wx.TextCtrl(self, size = (350,20), style = wx.TE_PROCESS_TAB)
    self.TextReplace = wx.TextCtrl(self, size = (350,20), style = wx.TE_PROCESS_TAB)
    self.SearchDirection = wx.RadioBox(self, -1, 'Search Direction',
     size = (110,-1), choices = ('Up','Down'), style = wx.RA_VERTICAL)
    self.SearchMode = wx.RadioBox(self, -1, 'Search Mode',
     size = (110, -1), choices = ('Text','Regex'), style = wx.RA_VERTICAL)
    self.Flags = wx.CheckListBox(self, -1, wx.DefaultPosition,
     (95,-1), ('Ignore Case','Whole Word(s)','Selection Only'), wx.VERTICAL)
    self.ButtonFind = wx.Button(self, wx.ID_FIND, 'Find')
    self.ButtonReplace = wx.Button(self, wx.ID_REPLACE, 'Replace')
    self.ButtonReplaceAll = wx.Button(self, wx.ID_REPLACE_ALL, 'Replace All')

How do I switch between them using Tab button?

Take a look at the wx.TAB_TRAVERSAL flag. There's some example code here (it also includes an alternate method): http://wiki.wxpython.org/Getting%20Started#How_to_get_tabs_to_work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM