Python wx 模块,EVT_CHOICE 实例源码

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

项目:Crypter    作者:sithis993    | 项目源码 | 文件源码
def set_events(self):
        '''
        @summary: Set GUI events for the various controls
        '''

        # Catch Language choice changes
        self.Bind(wx.EVT_CHOICE, self.update_language, self.BuilderLanguageChoice)

        # Catch config file load and save
        self.Bind(wx.EVT_FILEPICKER_CHANGED, self.__load_config, self.LoadFilePicker)
        self.Bind(wx.EVT_FILEPICKER_CHANGED, self.__save_config, self.SaveFilePicker)

        # BUILD button
        self.Bind(wx.EVT_BUTTON, self.__start_build, self.BuildButton)

        # Mainframe close
        self.Bind(wx.EVT_CLOSE, self.__close_builder, self)

        # Disable Open Containing Folder Button and bind event
        self.OpenContainingFolderButton.Disable()
        self.Bind(wx.EVT_BUTTON, self.__open_containing_folder, self.OpenContainingFolderButton)
项目:LalkaChat    作者:DeForce    | 项目源码 | 文件源码
def create_dropdown(**kwargs):
        panel = kwargs.get('panel')
        value = kwargs.get('value')
        key = kwargs.get('key')
        bind = kwargs.get('bind')
        gui = kwargs.get('gui')

        item_sizer = wx.BoxSizer(wx.HORIZONTAL)
        choices = gui.get('choices', [])
        item_name = MODULE_KEY.join(key)
        item_text = wx.StaticText(panel, label=translate_key(item_name))
        item_box = KeyChoice(panel, id=id_renew(item_name, update=True),
                             keys=choices, choices=choices)
        item_box.Bind(wx.EVT_CHOICE, bind)
        item_box.SetSelection(choices.index(value))
        item_sizer.Add(item_text, 0, wx.ALIGN_CENTER)
        item_sizer.Add(item_box)
        return {'item': item_sizer, 'text_size': item_text.GetSize()[0], 'text_ctrl': item_text}
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def _create_well_choice(self):
        self.index2uid = []
        items = []

        for well in self._OM.list('well'):
            uid = well.uid
            name = well.name

            self.index2uid.append(uid)
            items.append(name)

        well_choice = wx.Choice(self)
        well_choice.AppendItems(items)
        well_choice.Bind(wx.EVT_CHOICE, self.on_well_choice)

        return well_choice
项目:imagepy    作者:Image-Py    | 项目源码 | 文件源码
def add_choice(self, choices, tp, title, key, unit):
        sizer = wx.BoxSizer( wx.HORIZONTAL )
        lab_title = wx.StaticText( self, wx.ID_ANY, title,
                                   wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )

        lab_title.Wrap( -1 )
        sizer.Add( lab_title, 0, wx.ALIGN_CENTER|wx.ALL, 5 )

        ctrl = wx.Choice( self, wx.ID_ANY,
                          wx.DefaultPosition, wx.DefaultSize,
                          [str(choice) for choice in choices], 0 )

        ctrl.SetSelection(0)
        ctrl.SetValue = lambda x:ctrl.SetSelection(choices.index(x))
        ctrl.GetValue = lambda : tp(choices[ctrl.GetSelection()])
        self.ctrl_dic[key] = ctrl
        ctrl.Bind( wx.EVT_CHOICE, lambda x : self.para_changed(key))
        sizer.Add( ctrl, 2, wx.ALL, 5 )

        lab_unit = wx.StaticText( self, wx.ID_ANY, unit,
                                  wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_CENTRE )

        lab_unit.Wrap( -1 )
        sizer.Add( lab_unit, 0, wx.ALIGN_CENTER|wx.ALL, 5 )
        self.tus.append((lab_title, lab_unit))
        self.lst.Add( sizer, 0, wx.EXPAND, 5 )
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, welluid, *args, **kwargs):
        super(Dialog, self).__init__(*args, **kwargs)

        self.welluid = welluid
        self.partitionuid = None

        self._OM = ObjectManager(self)

        self.partitionmap = [pttn.uid for pttn in self._OM.list('partition', self.welluid)]
        partitionchoiceitems = [pttn.name for pttn in self._OM.list('partition', self.welluid)]

        self.partmap = []

        self.partitionchoice = wx.Choice(self)
        self.partitionchoice.AppendItems(partitionchoiceitems)
        self.partitionchoice.Bind(wx.EVT_CHOICE, self.on_partition_choice)

        self.partslistbox = wx.CheckListBox(self)

        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(self.partitionchoice, proportion=0, flag=wx.EXPAND)
        main_sizer.Add(self.partslistbox, proportion=1, flag=wx.EXPAND)
        main_sizer.AddSizer(button_sizer, proportion=0, flag=wx.ALIGN_RIGHT)

        self.SetSizer(main_sizer)

        if len(self.partitionmap) == 1:
            self.set_partitionuid(self.partitionmap[0])
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, *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__(*args, **kwargs)

        self._OM = ObjectManager(self)
        self._OM.subscribe(self.on_wells_changed, 'add')
        self._OM.subscribe(self.on_wells_changed, 'post_remove')    
        #self._OM.addcallback("add", self.on_wells_change)
        #self._OM.addcallback("post-remove", self.on_wells_change)

        self._mapui = []

        self.choice = wx.Choice(self)

        self.choice.Bind(wx.EVT_CHOICE, self.on_select)

        self.ls_panel = Panel(self)

        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
        self.Bind(wx.EVT_BUTTON, self.on_button)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.choice, flag=wx.ALIGN_CENTER)
        vbox.Add(self.ls_panel, 1, wx.ALL | wx.EXPAND)
        vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT)
        self.SetSizer(vbox)

        self.SetSize((400, 600))
        self.SetTitle(u"Seletor de Perfis para Plotagem")

        self.on_wells_change(None)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, *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__(*args, **kwargs)

        self._OM = ObjectManager(self)
        self._OM.subscribe(self.on_wells_changed, 'add')
        self._OM.subscribe(self.on_wells_changed, 'post_remove')
        #self._OM.addcallback('add_object', self.on_wells_changed)
        #self._OM.addcallback('post_remove_object', self.on_wells_changed)

        self.well_selector = wx.Choice(self)
        self.well_selector.Bind(wx.EVT_CHOICE, self.on_well_select)

        self.export_panel = Panel(self)

        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
        self.Bind(wx.EVT_BUTTON, self.on_button)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.well_selector, proportion=0, flag=wx.ALIGN_CENTER)
        vbox.Add(self.export_panel, proportion=1, flag=wx.ALL | wx.EXPAND)
        vbox.Add(button_sizer, flag=wx.ALIGN_RIGHT)
        self.SetSizer(vbox)

        self.SetSize((400, 600))
        self.SetTitle(u"Exportar:")

        self.welluid = None
        self.wellmap = []
        self.iwellmap = {}

        self.on_wells_changed(None)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        super(EncapsulatedChoice, self).__init__(*args, **kwargs)            
        self.control.Bind(wx.EVT_CHOICE, self.on_change)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def bind(self, handler, id):
        self._uiobj.Bind(wx.EVT_CHOICE, handler, id=id)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def bind(self, handler, id):
        self._uiobj.Bind(wx.EVT_CHOICE, handler, id=id)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, *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__(*args, **kwargs)

        self._OM = ObjectManager(self)
        self._OM.subscribe(self.on_wells_changed, 'add')
        self._OM.subscribe(self.on_wells_changed, 'post_remove')
        #self._OM.addcallback("add", self.on_wells_changed)
        #self._OM.addcallback("post-remove", self.on_wells_changed)

        self.wellselector = wx.Choice(self)
        self.wellselector.Bind(wx.EVT_CHOICE, self.on_well_select)

        self.crossplotselector = Panel(self)

        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
        self.Bind(wx.EVT_BUTTON, self.on_button)

        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.wellselector, 0, wx.ALIGN_CENTER, 5)
        vbox.Add(self.crossplotselector, 1, wx.ALL|wx.EXPAND, 5)
        vbox.Add(button_sizer, 0, wx.ALIGN_RIGHT, 5)
        self.SetSizer(vbox)

        self.SetSize((400, 600))
        self.Fit()
        self.SetTitle(u"Crossplot")

        self.welluid = None
        self.wellmap = []
        self.iwellmap = {}

        self.on_wells_changed(None)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        if 'size' not in kwargs:
            kwargs['size'] = (640, 480)

        super(Dialog, self).__init__(*args, **kwargs)

        self._OM = ObjectManager(self)

        self.currentwellindex = 0
        self.currentrocktableindex = 0

        self.tables = []

        self.rocktablemap = [rocktable.uid for rocktable in self._OM.list('rocktable')]
        work_table = []
        for rocktable in self._OM.list('rocktable'):
            work_table.append(RockTable(rocktable.uid))
        self.tables.append(work_table)
        self.grid = wx.grid.Grid(self)
        self.grid.SetDefaultColSize(100)

#        else:
        self.grid.SetTable(self.tables[self.currentwellindex][self.currentrocktableindex])
        self.grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.on_cell_dlclick)
        self.grid.Bind(wx.grid.EVT_GRID_LABEL_LEFT_DCLICK, self.on_label_dlclick)

        toolbar_sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.rocktable_choice = wx.Choice(self)
        self.rocktable_choice.AppendItems([self._OM.get(rocktableuid).name for rocktableuid in self.rocktablemap])
        self.rocktable_choice.SetSelection(self.currentrocktableindex)
        self.rocktable_choice.Bind(wx.EVT_CHOICE, self.on_rocktable_choice)

        add_rocktype_button = wx.Button(self, label='ADD ROCK TYPE')
        add_rocktype_button.Bind(wx.EVT_BUTTON, self.on_add_rocktype)

        remove_rocktype_button = wx.Button(self, label='REM ROCK TYPE')
        remove_rocktype_button.Bind(wx.EVT_BUTTON, self.on_remove_rocktype)

        toolbar_sizer.Add(self.rocktable_choice, 1, wx.ALIGN_LEFT)
        toolbar_sizer.Add(add_rocktype_button, 0, wx.ALIGN_LEFT)
        toolbar_sizer.Add(remove_rocktype_button, 0, wx.ALIGN_LEFT)

        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(toolbar_sizer, proportion=0, flag=wx.EXPAND)
        main_sizer.Add(self.grid, proportion=1, flag=wx.EXPAND)

        self.SetSizer(main_sizer)