Python wx 模块,WANTS_CHARS 实例源码

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

项目:Janet    作者:nosmokingbandit    | 项目源码 | 文件源码
def __init__(self):
        wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
                          title='Janet', size=(WIDTH, HEIGHT))
        self.SetMinSize((WIDTH, HEIGHT))

        self.browser = None

        global g_count_windows
        g_count_windows += 1

        self.setup_icon()
        # self.create_menu()
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        # Set wx.WANTS_CHARS style for the keyboard to work.
        # This style also needs to be set for all parent controls.
        self.browser_panel = wx.Panel(self, style=wx.WANTS_CHARS)
        self.browser_panel.Bind(wx.EVT_SET_FOCUS, self.OnSetFocus)
        self.browser_panel.Bind(wx.EVT_SIZE, self.OnSize)

        # On Linux must show before embedding browser, so that handle
        # is available.
        if LINUX:
            self.Show()
            self.embed_browser()
        else:
            self.embed_browser()
            self.Show()

        wx.CallLater(500, self.setup_gamepad)  # this has to be delayed to make sure the DOM has loaded the list of games
项目: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