我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用wx.LB_SINGLE。
def __init__(self, parent, id, title): wx.Dialog.__init__(self, parent, id, title) self.selection_idx = None self.selection_text = None vbox = wx.BoxSizer(wx.VERTICAL) stline = wx.StaticText( self, 11, 'Duplicate Component values found!' '\n\nPlease select which format to follow:') vbox.Add(stline, 0, wx.ALIGN_CENTER|wx.TOP) self.comp_list = wx.ListBox(self, 331, style=wx.LB_SINGLE) vbox.Add(self.comp_list, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND) self.SetSizer(vbox) self.comp_list.Bind(wx.EVT_LISTBOX_DCLICK, self.on_selection, id=wx.ID_ANY)
def __init__(self, parent=None,id=-1,title="Checking Spelling..."): wx.Dialog.__init__(self, parent, id, title, size=wxSpellCheckerDialog.sz, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) self._numContext = 40 self._checker = None self._buttonsEnabled = True self.error_text = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.TE_RICH) self.replace_text = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER) self.replace_list = wx.ListBox(self, -1, style=wx.LB_SINGLE) self.InitLayout() wx.EVT_LISTBOX(self,self.replace_list.GetId(),self.OnReplSelect) wx.EVT_LISTBOX_DCLICK(self,self.replace_list.GetId(),self.OnReplace)
def createLayout(self): self.listbox = wx.ListBox(self, ID_LISTBOX, wx.DefaultPosition, wx.DefaultSize, [], wx.LB_SINGLE | wx.LB_SORT, wx.DefaultValidator) self.listbox.typedText = "" s = "" try: if (os.name == "posix"): #s = "/dev/cu.PL2303-3B1\t" s = "/dev/ttyUSB0\t" if (os.name == "nt"): for i in range(1,10): s += "COM"+str(i)+"\t" except: print_exc() for i in s.split("\t"): if i: self.listbox.Append(i) self.bOK = wx.Button(self, ID_BUTTON_OK, "OK") self.bCancel = wx.Button(self, ID_BUTTON_CANCEL, "Cancel") self.sizer1 = wx.BoxSizer(wx.VERTICAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer2.Add(self.bOK, 1, wx.EXPAND|wx.ALL,10) self.sizer2.Add(self.bCancel, 1, wx.EXPAND|wx.ALL,10) self.sizer1.Add(self.listbox, 1, wx.EXPAND|wx.ALL,20) self.sizer1.Add(self.sizer2) self.SetSizer(self.sizer1) self.SetAutoLayout(1) self.sizer1.Fit(self) wx.EVT_LISTBOX_DCLICK(self, ID_LISTBOX, self.selectNewReaderOK) wx.EVT_BUTTON(self, ID_BUTTON_OK, self.selectNewReaderOK) wx.EVT_BUTTON(self, ID_BUTTON_CANCEL, self.selectNewReaderCancel)
def createLayout(self): self.listbox = wx.ListBox(self, ID_LISTBOX, wx.DefaultPosition, wx.DefaultSize, [], wx.LB_SINGLE | wx.LB_SORT, wx.DefaultValidator) self.listbox.typedText = "" try: s = self.pcsc.listAllReaders() except: print_exc() for i in s.split("\t"): if i: self.listbox.Append(i) self.bOK = wx.Button(self, ID_BUTTON_OK, "OK") self.bCancel = wx.Button(self, ID_BUTTON_CANCEL, "Cancel") self.sizer1 = wx.BoxSizer(wx.VERTICAL) self.sizer2 = wx.BoxSizer(wx.HORIZONTAL) self.sizer2.Add(self.bOK, 1, wx.EXPAND|wx.ALL,10) self.sizer2.Add(self.bCancel, 1, wx.EXPAND|wx.ALL,10) self.sizer1.Add(self.listbox, 1, wx.EXPAND|wx.ALL,20) self.sizer1.Add(self.sizer2) self.SetSizer(self.sizer1) self.SetAutoLayout(1) self.sizer1.Fit(self) wx.EVT_LISTBOX_DCLICK(self, ID_LISTBOX, self.selectNewReaderOK) wx.EVT_BUTTON(self, ID_BUTTON_OK, self.selectNewReaderOK) wx.EVT_BUTTON(self, ID_BUTTON_CANCEL, self.selectNewReaderCancel)
def initSelectorArea(self): self.selectorSizer = wx.BoxSizer(orient=wx.VERTICAL) filterListControlBox = widgets.ControlBox(self, label='Available Filters', orient=wx.VERTICAL) self.filterListBox = wx.ListBox(self, choices=filters.filterChoices.keys(), style=wx.LB_SORT | wx.LB_SINGLE) filterListControlBox.Add(self.filterListBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) self.pushFilterButton = wx.Button(self, label='Push Filter') self.Bind(wx.EVT_BUTTON, self.pushFilter, self.pushFilterButton) filterListControlBox.Add(self.pushFilterButton, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.selectorSizer.Add(filterListControlBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) chainListControlBox = widgets.ControlBox(self, label='Filter Chain', orient=wx.VERTICAL) self.chainListBox = wx.ListBox(self, choices=[], style=wx.LB_SINGLE) ##self.chainListBox = wx.ListCtrl(self, style=wx.LC_NO_HEADER | wx.LC_SINGLE_SEL) self.Bind(wx.EVT_LISTBOX, self.configFilter, self.chainListBox) chainListControlBox.Add(self.chainListBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=10) #self.configFilterButton = wx.Button(self, label='Configure Filter') #self.Bind(wx.EVT_BUTTON, self.configFilter, self.configFilterButton) #chainListControlBox.Add(self.configFilterButton, proportion=0, # flag=wx.LEFT | wx.RIGHT | wx.EXPAND, border=10) self.popFilterButton = wx.Button(self, label='Pop Filter') self.Bind(wx.EVT_BUTTON, self.popFilter, self.popFilterButton) chainListControlBox.Add(self.popFilterButton, proportion=0, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10) self.selectorSizer.Add(chainListControlBox, proportion=1, flag=wx.LEFT | wx.BOTTOM | wx.RIGHT | wx.EXPAND, border=10)
def initMusicLists(self): self.albumControlBox = ControlBox(self, label='Albums', orient=wx.VERTICAL) self.albumListBox = wx.ListBox(self, choices=[], style=wx.LB_SINGLE) self.albumControlBox.Add(self.albumListBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=5) self.songControlBox = ControlBox(self, label='Songs', orient=wx.VERTICAL) self.songListBox = wx.ListBox(self, choices=[], style=wx.LB_SINGLE) self.songControlBox.Add(self.songListBox, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
def __init__(self, parent, choices=[]): wx.PopupWindow.__init__(self, parent, wx.BORDER_SIMPLE) self.ListBox = wx.ListBox(self, -1, style=wx.LB_HSCROLL | wx.LB_SINGLE | wx.LB_SORT) self.SetChoices(choices) self.ListBox.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown) self.ListBox.Bind(wx.EVT_MOTION, self.OnMotion)
def __init__(self, parent, id, title): wx.Dialog.__init__(self, parent, id, title) self.selection_idx = None self.selection_text = None vbox = wx.BoxSizer(wx.VERTICAL) stline = wx.StaticText(self, 11, 'Please select from the following components') vbox.Add(stline, 0, wx.ALIGN_CENTER|wx.TOP) self.comp_list = wx.ListBox(self, 331, style=wx.LB_SINGLE) vbox.Add(self.comp_list, 1, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND) self.SetSizer(vbox) self.comp_list.Bind(wx.EVT_LISTBOX, self.on_selection, id=wx.ID_ANY)
def __init__(self, *args, **kwds): # begin wxGlade: add_div.__init__ kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.STAY_ON_TOP wx.Dialog.__init__(self, *args, **kwds) self.panel_1 = wx.ScrolledWindow(self, -1, style=wx.TAB_TRAVERSAL) self.label_1 = wx.StaticText(self.panel_1, -1, "YEAR") self.combo_box_1 = wx.ComboBox(self.panel_1, -1, choices=[], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT) self.label_2 = wx.StaticText(self.panel_1, -1, "CLASS") self.combo_box_2 = wx.ComboBox(self.panel_1, -1, choices=["Select","8","9","10"], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN | wx.CB_READONLY | wx.CB_SORT) self.sizer_4_staticbox = wx.StaticBox(self.panel_1, -1, "Specify Class ") self.list_box_1 = wx.ListBox(self.panel_1, -1, choices=[], style=wx.LB_SINGLE | wx.LB_SORT) self.button_1 = wx.Button(self.panel_1, -1, "Remove Divison") self.text_ctrl_1 = wx.TextCtrl(self.panel_1, -1, "") self.button_2 = wx.Button(self.panel_1, -1, "Add Division") self.sizer_9_staticbox = wx.StaticBox(self.panel_1, -1, "New Division") self.button_3 = wx.Button(self.panel_1, -1, "Close") self.hyperlink_1 = wx.HyperlinkCtrl(self.panel_1, wx.ID_ANY, "", "Add Academic Year") self.__set_properties() self.__do_layout() self.Bind(wx.EVT_COMBOBOX, self.on_year, self.combo_box_1) self.Bind(wx.EVT_COMBOBOX, self.on_class, self.combo_box_2) self.Bind(wx.EVT_LISTBOX, self.on_list, self.list_box_1) self.Bind(wx.EVT_BUTTON, self.on_remove, self.button_1) self.Bind(wx.EVT_TEXT, self.on_text, self.text_ctrl_1) self.Bind(wx.EVT_BUTTON, self.on_add, self.button_2) self.Bind(wx.EVT_BUTTON, self.on_close, self.button_3) self.text_ctrl_1 .Bind(wx.EVT_SET_FOCUS,self.onfocus) self.text_ctrl_1 .Bind(wx.EVT_KILL_FOCUS,self.offocus) self.text_ctrl_1.Bind(wx.EVT_KEY_DOWN, self.on_keypress) self.Bind(wx.EVT_HYPERLINK, self.on_hlink, self.hyperlink_1) self.YEAR='' self.CLASS='' self.DB=db_operations() self.load_year() # end wxGlade