Python wx 模块,EVT_LIST_ITEM_SELECTED 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用wx.EVT_LIST_ITEM_SELECTED

项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
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)
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
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)
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
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)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnClickUp(self, event):
        itemcount = self.mainlist.GetItemCount()
        if self.CurrentListItem <= 0:
            return
        item_selected = -1
        for i in range(itemcount):
            if self.mainlist.IsSelected(i):
                item_selected = i
                break
        if item_selected > 0:
            item = item_selected-1
            item_next = item_selected
            t = self.mainlist.GetItem(item_next,1).GetText()
            ischecked = self.mainlist.IsChecked(item_next)
            self.mainlist.DeleteItem(item_next)
            if IsNotWX4():
                mainlistidx = self.mainlist.InsertStringItem(item,"")
            else:
                mainlistidx = self.mainlist.InsertItem(item,"")
            if ischecked:
                self.mainlist.CheckItem(mainlistidx)
            if IsNotWX4():
                self.mainlist.SetStringItem(mainlistidx, 1, t)
            else:
                self.mainlist.SetItem(mainlistidx, 1, t)
            self.mainlist.Select(item, 1)
            self.pipelineitems[item], self.pipelineitems[item_next] = self.pipelineitems[item_next], self.pipelineitems[item]
            cmd = wx.ListEvent(wx.EVT_LIST_ITEM_SELECTED.typeId, self.mainlist.GetId())
            if IsNotWX4():
                cmd.m_itemIndex = item
            else:
                cmd.SetIndex(item)
            self.mainlist.GetEventHandler().ProcessEvent(cmd)
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnClickDown(self, event):
        itemcount = self.mainlist.GetItemCount()
        if self.CurrentListItem < 0 or self.CurrentListItem == (itemcount - 1):
            return
        item_selected = -1
        for i in range(itemcount):
            if self.mainlist.IsSelected(i):
                item_selected = i
                break
        if item_selected < itemcount-1:
            item = item_selected+1
            item_next = item_selected
            t = self.mainlist.GetItem(item_next,1).GetText()
            ischecked = self.mainlist.IsChecked(item_next)
            self.mainlist.DeleteItem(item_next)
            if IsNotWX4():
                mainlistidx = self.mainlist.InsertStringItem(item,"")
            else:
                mainlistidx = self.mainlist.InsertItem(item,"")
            if ischecked:
                self.mainlist.CheckItem(mainlistidx)
            if IsNotWX4():
                self.mainlist.SetStringItem(mainlistidx, 1, t)
            else:
                self.mainlist.SetItem(mainlistidx, 1, t)
            self.pipelineitems[item], self.pipelineitems[item_next] = self.pipelineitems[item_next], self.pipelineitems[item]
            self.mainlist.Select(item, 1)
            cmd = wx.ListEvent(wx.EVT_LIST_ITEM_SELECTED.typeId, self.mainlist.GetId())
            if IsNotWX4():
                cmd.m_itemIndex = item
            else:
                cmd.SetIndex(item)
            self.mainlist.GetEventHandler().ProcessEvent(cmd)
项目:hachoir3    作者:vstinner    | 项目源码 | 文件源码
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)
项目:BigBrotherBot-For-UrT43    作者:ptitbigorneau    | 项目源码 | 文件源码
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)
项目:paho.mqtt.testing    作者:eclipse    | 项目源码 | 文件源码
def __init__(self):
    global myWindow
    wx.Frame.__init__(self, None, -1, "MQTT Protocol Trace", size=(600, 400))
    self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
    self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OpenDetails)

    self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT)
    self.statusBar = self.CreateStatusBar()
    menubar = wx.MenuBar()
    menu1 = wx.Menu()
    clear = menu1.Append(wx.NewId(), "&Clear")
    self.Bind(wx.EVT_MENU, self.OnClear, clear)
    saveas = menu1.Append(wx.NewId(), "&Save as")
    self.Bind(wx.EVT_MENU, self.OnSaveAs, saveas)
    menubar.Append(menu1, "&File")
    self.SetMenuBar(menubar)

    for index, title in enumerate(cols):
      self.list.InsertColumn(index, title)
      self.list.SetColumnWidth(index, widths[index])

    self.listitem = 0
    listmix.ColumnSorterMixin.__init__(self, len(cols))

    self.itemDataMap = {}

    myWindow = self
    self.thread = WorkerThread()
    self.thread.start()
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def __init__(self, parent):
        """Constructor"""
        wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)

        # self.Bind(wx.EVT_BUTTON, self.OnSelectFont, btn)

        self.list_ctrl = theListCtrl(self, -1, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_VRULES | wx.SUNKEN_BORDER)
        st1 = wx.StaticText(self, label=' Cadena Busqueda')
        self.cadenaBusqueda = wx.TextCtrl(self)
        btnbusqueda = wx.Button(self, label="Buscar")
        btnrecargaVM = wx.Button(self, label="Actualizar VM")

        name_rows = ['Carpeta', 'Nombre', 'IP', 'Estado', 'pregunta', 'Disco Path', 'Sistema', 'Notas', 'uuid']

        # cargamos los nombres de los elementos
        for x in range(len(name_rows)):
            self.list_ctrl.InsertColumn(x, name_rows[x])

        # conexion = conectar_con_vcenter(self, id)
        self.tabla = []
        self.tabla = sacar_listado_capertas(conexion)
        self.vm_buscados = []

        self.cargardatos_en_listctrl(self.tabla)

        # para la ordenacion--- llama a Getlistctrl
        self.itemDataMap = self.tabla
        listmix.ColumnSorterMixin.__init__(self, len(name_rows))
        self.list_ctrl.Bind(wx.EVT_LIST_ITEM_SELECTED, self.onItemSelected, self.list_ctrl)
        # self.list_ctrl.Bind(wx.EVT_CONTEXT_MENU, self.onItemSelected, self.list_ctrl)

        # Metemos las cosas en le ventana en orden
        txtcontador = wx.StaticText(self, label='total VM: ' + str(len(self.tabla)))
        sizer = wx.BoxSizer(wx.VERTICAL)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox1.Add(st1, wx.ALL | wx.ALIGN_CENTER, 5)
        hbox1.Add(self.cadenaBusqueda, wx.ALL | wx.ALIGN_CENTER, 5)
        hbox1.Add(btnbusqueda, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER, 5)
        hbox1.Add(btnrecargaVM, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER, 5)
        hbox1.Add(txtcontador, wx.ALL | wx.ALIGN_CENTER, 5)
        sizer.Add(hbox1, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP | wx.ALIGN_CENTER, border=2)
        self.Bind(wx.EVT_BUTTON, self.busquedadatos, btnbusqueda)
        self.Bind(wx.EVT_BUTTON, self.recarga_VM, btnrecargaVM)

        sizer.Add(self.list_ctrl, 1, wx.ALL | wx.EXPAND, 5)
        self.SetSizer(sizer)

        # tools for search an debug (to use uncomment the next line, works only linux)
        # wx.lib.inspection.InspectionTool().Show()

    # ----------------------------------------------------------------------
    # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def __init__(self, parent):
        wx.Dialog.__init__(self, parent, title="Lookup Table", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
        self.SetSizeHints(720,480,-1,-1)
        self.parent = parent
        self.Bind(wx.EVT_CLOSE, self.OnExit)
        self.panelphase = parent.GetParent().GetPage(0)
        self.panelvisual = self.GetParent()
        self.actor_list3D = ["vtkOpenGLActor", "vtkActor", "vtkMesaActor"]
        self.actor_list2D = ["vtkOpenGLImageActor", "vtkImageActor"]
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.hbox = wx.BoxSizer(wx.HORIZONTAL)
        self.vbox1 = wx.BoxSizer(wx.VERTICAL)
        self.vbox2 = wx.BoxSizer(wx.VERTICAL)
        self.font = self.panelvisual.font
        self.panels = []
        self.listtitles = ["Real Amp","Real Phase", "Fourier Amp","Fourier Phase"]
        self.list = wx.ListCtrl(self,wx.ID_ANY,style=wx.LC_REPORT|wx.LC_NO_HEADER|wx.LC_HRULES|wx.SUNKEN_BORDER, size=(200,-1))
        self.list.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelectListItem)
        self.list.InsertColumn(0,'Settings', width = 200)
        self.list.SetFont(self.font)
        for i in range(len(self.listtitles)):
            if IsNotWX4():
                self.list.InsertStringItem(i,self.listtitles[i],i)
            else:
                self.list.InsertItem(i,self.listtitles[i],i)
            self.list.SetItemFont(i, self.font)
            self.panels.append(ColourDialog(self))
            self.panels[-1].Hide()
            self.panels[-1].Layout()
            self.GetRadioChoice(i)
            self.vbox2.Add(self.panels[-1], 1, wx.EXPAND)
        self.vbox1.Add(self.list, 1, wx.EXPAND)
        self.panel_hld = wx.StaticText(self, label='')
        self.vbox2.Add(self.panel_hld, 1, wx.EXPAND)
        self.hbox.Add(self.vbox1, 0, wx.EXPAND,2)
        self.hbox.Add(self.vbox2, 1, wx.EXPAND,2)
        self.sizer.Add(self.hbox, 1, wx.EXPAND,2)
        self.button_update = wx.Button(self, label="Update Scale", size=(720, 30))
        self.sizer.Add(self.button_update, 0, wx.EXPAND, 2)
        self.Bind(wx.EVT_BUTTON, self.OnClickUpdate,self.button_update)
        self.SetSizer(self.sizer)
        self.Fit()
        self.Layout()
        self.Show()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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()