我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用wx.EVT_LIST_ITEM_ACTIVATED。
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, parent ): win_height = parent.GetSize()[1] win_width = parent.GetSize()[0] w_space_left = win_width - 285 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = (285, 0), size = wx.Size(w_space_left , 800), style = wx.TAB_TRAVERSAL ) ## Draw UI elements png = wx.Image('./config_info.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap() wx.StaticBitmap(self, -1, png, (0, 0), (png.GetWidth(), png.GetHeight())) #SDcard details config_info_pnl.boxname_text = wx.TextCtrl(self, pos=(25, 150), size=(265,65)) config_info_pnl.location_text = wx.StaticText(self, label='locations', pos=(520, 120), size=(200,30)) config_info_pnl.config_text = wx.StaticText(self, label='config', pos=(520, 185), size=(200,30)) config_info_pnl.lamp_text = wx.StaticText(self, label='lamp', pos=(10, 330), size=(200,30)) config_info_pnl.dht_text = wx.StaticText(self, label='dht', pos=(10, 415), size=(200,30)) config_info_pnl.gpio_table = self.GPIO_list(self, 1) config_info_pnl.gpio_table.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_GPIO)
def __init__( self, parent ): #find size win_height = parent.GetSize()[1] win_width = parent.GetSize()[0] w_space_left = win_width - 285 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = (285, 0), size = wx.Size(w_space_left , 800), style = wx.TAB_TRAVERSAL ) wx.StaticText(self, label='Cron start up;', pos=(5, 10)) cron_list_pnl.startup_cron = self.startup_cron_list(self, 1, pos=(5, 40), size=(w_space_left-10, 200)) cron_list_pnl.startup_cron.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_startup) wx.StaticText(self, label='Repeating Jobs;', pos=(5,245)) cron_list_pnl.repeat_cron = self.repeating_cron_list(self, 1, pos=(5, 280), size=(w_space_left-10, 200)) cron_list_pnl.repeat_cron.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_repeat) wx.StaticText(self, label='One time triggers;', pos=(5,500)) cron_list_pnl.timed_cron = self.other_cron_list(self, 1, pos=(5, 530), size=(w_space_left-10, 200)) cron_list_pnl.timed_cron.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_timed) # TESTING CODE WHILE SCRIPT WRITING IS IN PROGRESS self.SetBackgroundColour('sea green') ###THIS IS JUST TO TEST SIZE REMOVE TO STOP THE UGLY
def __init__( self, parent ): win_height = parent.GetSize()[1] win_width = parent.GetSize()[0] w_space_left = win_width - 285 wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = (285, 0), size = wx.Size(w_space_left , 800), style = wx.TAB_TRAVERSAL ) #set blank variables localfiles_info_pnl.local_path = "" ## Draw UI elements png = wx.Image('./localfiles.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap() wx.StaticBitmap(self, -1, png, (0, 0), (png.GetWidth(), png.GetHeight())) # placing the information boxes localfiles_info_pnl.local_path_txt = wx.StaticText(self, label='local path', pos=(220, 80), size=(200,30)) #local photo storage info localfiles_info_pnl.caps_folder = 'caps' localfiles_info_pnl.folder_text = wx.StaticText(self, label=' ' + localfiles_info_pnl.caps_folder, pos=(720, 130), size=(200,30)) localfiles_info_pnl.photo_text = wx.StaticText(self, label='photo text', pos=(575, 166), size=(170,30)) localfiles_info_pnl.first_photo_title = wx.StaticText(self, label='first image', pos=(575, 290), size=(170,30)) localfiles_info_pnl.last_photo_title = wx.StaticText(self, label='last image', pos=(575, 540), size=(170,30)) #file list boxes localfiles_info_pnl.config_files = self.config_file_list(self, 1, pos=(5, 160), size=(550, 200)) localfiles_info_pnl.config_files.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_config) localfiles_info_pnl.logs_files = self.logs_file_list(self, 1, pos=(5, 390), size=(550, 200)) localfiles_info_pnl.logs_files.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_logs) #localfiles_info_pnl.config_files = self.config_file_list(self, 1, pos=(5, 160), size=(550, 200)) # localfiles_info_pnl.config_files.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.onDoubleClick_config) #cron info text localfiles_info_pnl.cron_info = wx.StaticText(self, label='cron info', pos=(290, 635), size=(200,30))
def __init__( self, parent,): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = 'Plugin List', pos = wx.DefaultPosition, size = wx.Size( 612,500 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) logopath = os.path.join(root_dir, 'data/logo.ico') self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) ) self.SetIcon(wx.Icon(logopath, wx.BITMAP_TYPE_ICO)) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.VERTICAL ) bSizer2 = wx.BoxSizer( wx.HORIZONTAL ) self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, "Search:", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) bSizer2.Add( self.m_staticText1, 0, wx.ALIGN_CENTER|wx.ALL, 5 ) self.txt_search = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer2.Add( self.txt_search, 1, wx.ALL, 5 ) bSizer1.Add( bSizer2, 0, wx.EXPAND, 5 ) self.lst_plgs = VirtualListCtrl( self, ['Name', 'Location']) self.lst_plgs.SetColumnWidth(0,200) self.lst_plgs.SetColumnWidth(1,400) bSizer1.Add( self.lst_plgs, 1, wx.ALL|wx.EXPAND, 5 ) self.SetSizer( bSizer1 ) self.Layout() self.Centre( wx.BOTH ) # Connect Events self.txt_search.Bind( wx.EVT_TEXT, self.on_search ) self.lst_plgs.Bind( wx.EVT_LIST_ITEM_ACTIVATED, self.on_run ) self.load()
def __init__(self, parent, filetypes, fileLimit = None): wx.Dialog.__init__(self, parent, -1, title = 'Select Input Files', style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.filetypes = {} self.fileArray = wx.ListCtrl(self, -1, style = wx.LC_REPORT | wx.LC_EDIT_LABELS | wx.LC_HRULES | wx.LC_VRULES) for i, (filetype, ext) in enumerate(filetypes): self.fileArray.InsertColumn(i, filetype) assert filetype not in self.filetypes, "Non-unique file identifiers! %s" % filetype self.filetypes[filetype] = ext self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.getFile, self.fileArray) self.goButton = wx.Button(self, -1, "Use Selected Files") self.Bind(wx.EVT_BUTTON, self.complete, self.goButton) self.Bind(wx.EVT_CLOSE, self.abort) box = wx.BoxSizer(wx.VERTICAL) box.Add(self.fileArray, 1, wx.ALL | wx.EXPAND, 10) box.Add(self.goButton, 0, wx.ALL | wx.EXPAND, 10) self.SetSizerAndFit(box) self.SetSize(wx.Size(1200, 300)) self.Bind(wx.EVT_SIZE, self.resize) for i in range(0, 10): self.fileArray.Append([''] * self.fileArray.GetColumnCount()) self.resize(None) self.CentreOnScreen()
def on_field_view_ready(self, dispatcher, field_view): assert field_view is not None field_view.Bind(wx.EVT_COMMAND_RIGHT_CLICK, self.on_item_right_clicked) field_view.Bind(wx.EVT_RIGHT_UP, self.on_item_right_clicked) field_view.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_item_activated) field_view.Bind(wx.EVT_LIST_ITEM_SELECTED, self.on_item_selected)
def CreateControls(self): """Create our sub-controls""" wx.EVT_LIST_COL_CLICK(self, self.GetId(), self.OnReorder) wx.EVT_LIST_ITEM_SELECTED(self, self.GetId(), self.OnNodeSelected) wx.EVT_MOTION(self, self.OnMouseMove) wx.EVT_LIST_ITEM_ACTIVATED(self, self.GetId(), self.OnNodeActivated) for i, column in enumerate(self.columns): column.index = i self.InsertColumn(i, column.name) if not windows or column.targetWidth is None: self.SetColumnWidth(i, wx.LIST_AUTOSIZE) else: self.SetColumnWidth(i, column.targetWidth) self.SetItemCount(0)
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()