我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用wx.LC_SINGLE_SEL。
def createWidgets(self): self.listCtrl = wxskinListCtrl(self, ID_LISTCTRL, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL|wx.LC_VRULES|wx.LC_HRULES) self.listCtrl.InsertColumn(0, "Name") self.listCtrl.InsertColumn(1, "Number") ColumnSorterMixin.__init__(self, 2) self.currentItem = 0 wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_SELECTED(self, ID_LISTCTRL, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL, self.OnItemActivated) wx.EVT_CLOSE(self, self.closeWindow) wx.EVT_LEFT_DCLICK(self.listCtrl, self.OnPopupEdit) wx.EVT_RIGHT_DOWN(self.listCtrl, self.OnRightDown) # for wxMSW and wxGTK respectively wx.EVT_COMMAND_RIGHT_CLICK(self.listCtrl, ID_LISTCTRL, self.OnRightClick) wx.EVT_RIGHT_UP(self.listCtrl, self.OnRightClick)
def createWidgets(self): self.listCtrl = wxskinListCtrl(self, ID_LISTCTRL, style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL|wx.LC_VRULES|wx.LC_HRULES) self.listCtrl.InsertColumn(COL_STATUS, "Status") self.listCtrl.InsertColumn(COL_DATE, "Date") self.listCtrl.InsertColumn(COL_FROM, "From") self.listCtrl.InsertColumn(COL_MESSAGE, "Message") ColumnSorterMixin.__init__(self, 4) self.currentItem = 0 wx.EVT_SIZE(self, self.OnSize) wx.EVT_LIST_ITEM_SELECTED(self, ID_LISTCTRL, self.OnItemSelected) wx.EVT_LIST_ITEM_ACTIVATED(self, ID_LISTCTRL, self.OnItemActivated) wx.EVT_RIGHT_DOWN(self.listCtrl, self.OnRightDown) wx.EVT_LEFT_DCLICK(self.listCtrl, self.OnPopupEdit) wx.EVT_CLOSE(self, self.closeWindow) # for wxMSW and wxGTK respectively wx.EVT_COMMAND_RIGHT_CLICK(self.listCtrl, ID_LISTCTRL, self.OnRightClick) wx.EVT_RIGHT_UP(self.listCtrl, self.OnRightClick)
def __init__(self): wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, title='Moogle HTTP to OPC Server', size=(800,600) ) sizer = wx.BoxSizer(wx.VERTICAL) self.row_colours = { 'rest': 'blue', 'opc': 'purple'} ## -- Configure Top Tool bar tb = wx.ToolBar(self, style=TBFLAGS) sizer.Add(tb, 0, wx.EXPAND) tsize = (24,24) tb.SetToolBitmapSize(tsize) tb.Realize() self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT #| wx.BORDER_SUNKEN #| wx.BORDER_NONE | wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING | wx.LC_NO_HEADER | wx.LC_VRULES | wx.LC_HRULES #| wx.LC_SINGLE_SEL ) self.loadListviewHeader() sizer.Add(self.list, 1, wx.EXPAND) self.SetSizer(sizer) sizer.Layout() self.Bind(wx.EVT_CLOSE, self.onClose)
def __init__(self, *arg, **kw): if 'style' in kw and (kw['style']&wx.LC_LIST or kw['style']&wx.LC_REPORT): kw['style'] |= wx.LC_SINGLE_SEL else: kw['style'] = wx.LC_SINGLE_SEL|wx.LC_LIST wx.ListCtrl.__init__(self, *arg, **kw) self.Bind(wx.EVT_LIST_BEGIN_DRAG, self._startDrag) dt = ListDrop(self._insert) self.SetDropTarget(dt)
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 __init__(self, parent, id, bmpsize=(24,24), size=(180,1)): wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT|wx.LC_NO_HEADER|wx.LC_HRULES|wx.SUNKEN_BORDER|wx.LC_SINGLE_SEL, size=(180,1)) ListCtrlAutoWidthMixin.__init__(self) bmpchk = getpipelineok24Bitmap() bmpunchk = getpipelineignore24Bitmap() CheckListCtrlMixin.__init__(self,check_image=bmpchk,uncheck_image=bmpunchk, imgsz=bmpsize)
def __init__(self, parent, names, units, curvetypes, datatypes, *args, **kwargs): if 'on_ok_callback' in kwargs: self.on_ok_callback = kwargs.pop('on_ok_callback') else: self.on_ok_callback = None if 'on_cancel_callback' in kwargs: self.on_cancel_callback = kwargs.pop('on_cancel_callback') else: self.on_cancel_callback = None super(Dialog, self).__init__(parent, *args, **kwargs) self.names = names self.units = units self.curvetypes = curvetypes self.datatypes = datatypes self.nrows = len(self.names) style = wx.LC_REPORT | wx.LC_VRULES | wx.LC_HRULES | wx.LC_SINGLE_SEL | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT self.list = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=style) self._fill_list() button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL) self.Bind(wx.EVT_BUTTON, self.on_button) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.list, proportion=1, flag=wx.EXPAND) vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT) self.SetSizerAndFit(vbox) self.SetSize((400, 600)) self.SetTitle(u"Importar como:")
def _init_ctrls(self, prnt): wx.Dialog.__init__( self, id=ID_DISCOVERYDIALOG, name='DiscoveryDialog', parent=prnt, style=wx.DEFAULT_DIALOG_STYLE, title=_('Service Discovery')) self.staticText1 = wx.StaticText( id=ID_DISCOVERYDIALOGSTATICTEXT1, label=_('Services available:'), name='staticText1', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) # Set up list control self.ServicesList = AutoWidthListCtrl( id=ID_DISCOVERYDIALOGSERVICESLIST, name='ServicesList', parent=self, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.LC_REPORT | wx.LC_EDIT_LABELS | wx.LC_SORT_ASCENDING | wx.LC_SINGLE_SEL) self.ServicesList.InsertColumn(0, _('NAME')) self.ServicesList.InsertColumn(1, _('TYPE')) self.ServicesList.InsertColumn(2, _('IP')) self.ServicesList.InsertColumn(3, _('PORT')) self.ServicesList.SetColumnWidth(0, 150) self.ServicesList.SetColumnWidth(1, 150) self.ServicesList.SetColumnWidth(2, 150) self.ServicesList.SetColumnWidth(3, 150) self.ServicesList.SetInitialSize(wx.Size(-1, 300)) self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected, id=ID_DISCOVERYDIALOGSERVICESLIST) self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnItemActivated, id=ID_DISCOVERYDIALOGSERVICESLIST) listmix.ColumnSorterMixin.__init__(self, 4) self.RefreshButton = wx.Button( id=ID_DISCOVERYDIALOGREFRESHBUTTON, label=_('Refresh'), name='RefreshButton', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.Bind(wx.EVT_BUTTON, self.OnRefreshButton, id=ID_DISCOVERYDIALOGREFRESHBUTTON) self.LocalButton = wx.Button( id=ID_DISCOVERYDIALOGLOCALBUTTON, label=_('Local'), name='LocalButton', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.Bind(wx.EVT_BUTTON, self.OnLocalButton, id=ID_DISCOVERYDIALOGLOCALBUTTON) self.IpButton = wx.Button( id=ID_DISCOVERYDIALOGIPBUTTON, label=_('Add IP'), name='IpButton', parent=self, pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) self.Bind(wx.EVT_BUTTON, self.OnIpButton, id=ID_DISCOVERYDIALOGIPBUTTON) self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTER) self._init_sizers() self.Fit()