Python wx.ComboBox() Examples

The following are 30 code examples of wx.ComboBox(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: misc.py    From trelby with GNU General Public License v2.0 6 votes vote down vote up
def addCombo(self, name, descr, parent, sizer, items, sel):
        al = wx.ALIGN_CENTER_VERTICAL | wx.RIGHT
        if sel == 1:
            al |= wx.ALIGN_RIGHT

        sizer.Add(wx.StaticText(parent, -1, descr), 0, al, 10)

        combo = wx.ComboBox(parent, -1, style = wx.CB_READONLY)
        util.setWH(combo, w = 200)

        for s in items:
            combo.Append(s)

        combo.SetSelection(sel)

        sizer.Add(combo)

        setattr(self, name + "Combo", combo) 
Example #2
Source File: GUI_wxPython.py    From Python-GUI-Programming-Cookbook-Third-Edition with MIT License 6 votes vote down vote up
def addStaticBoxWithLabels(self):
        boxSizerH = wx.BoxSizer(wx.HORIZONTAL)
        staticBox = wx.StaticBox( self.panel, -1, "Labels within a Frame" )
        staticBoxSizerV = wx.StaticBoxSizer( staticBox, wx.VERTICAL )
        boxSizerV = wx.BoxSizer( wx.VERTICAL )
        staticText1 = wx.StaticText( self.panel, -1, " Choose a number:" )
        boxSizerV.Add( staticText1, 0, wx.ALL)
        staticText2 = wx.StaticText( self.panel, -1, "           Label 2")
        boxSizerV.Add( staticText2, 0, wx.ALL )
        #------------------------------------------------------
        staticBoxSizerV.Add( boxSizerV, 0, wx.ALL )
        boxSizerH.Add(staticBoxSizerV)
        #------------------------------------------------------
        boxSizerH.Add(wx.ComboBox(self.panel, size=(70, -1)))
        #------------------------------------------------------
        boxSizerH.Add(wx.SpinCtrl(self.panel, size=(50, -1), style=wx.BORDER_RAISED))             
        
        # Add local boxSizer to main frame
        self.statBoxSizerV.Add( boxSizerH, 1, wx.ALL )

    #---------------------------------------------------------- 
Example #3
Source File: dfgui.py    From PandasDataFrameGUI with MIT License 6 votes vote down vote up
def __init__(self, parent, columns, df_list_ctrl):
        wx.Panel.__init__(self, parent)

        columns_with_neutral_selection = [''] + list(columns)
        self.columns = columns
        self.df_list_ctrl = df_list_ctrl

        self.figure = Figure(facecolor="white", figsize=(1, 1))
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)

        chart_toolbar = NavigationToolbar2Wx(self.canvas)

        self.combo_box1 = wx.ComboBox(self, choices=columns_with_neutral_selection, style=wx.CB_READONLY)

        self.Bind(wx.EVT_COMBOBOX, self.on_combo_box_select)

        row_sizer = wx.BoxSizer(wx.HORIZONTAL)
        row_sizer.Add(self.combo_box1, 0, wx.ALL | wx.ALIGN_CENTER, 5)
        row_sizer.Add(chart_toolbar, 0, wx.ALL, 5)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, flag=wx.EXPAND, border=5)
        sizer.Add(row_sizer)
        self.SetSizer(sizer) 
Example #4
Source File: flagpage.py    From magpy with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def createControls(self):
        self.flagOptionsLabel = wx.StaticText(self, label="Flagging methods:")
        self.flagOutlierButton = wx.Button(self,-1,"Flag Outlier",size=(160,30))
        self.flagRangeButton = wx.Button(self,-1,"Flag Range",size=(160,30))
        self.flagMinButton = wx.Button(self,-1,"Flag Minimum",size=(160,30))
        self.flagMaxButton = wx.Button(self,-1,"Flag Maximum",size=(160,30))
        self.xCheckBox = wx.CheckBox(self,label="X             ")
        self.yCheckBox = wx.CheckBox(self,label="Y             ")
        self.zCheckBox = wx.CheckBox(self,label="Z             ")
        self.fCheckBox = wx.CheckBox(self,label="F             ")
        self.FlagIDText = wx.StaticText(self,label="Select Min/Max Flag ID:")
        self.FlagIDComboBox = wx.ComboBox(self, choices=self.flagidlist,
            style=wx.CB_DROPDOWN, value=self.flagidlist[3],size=(160,-1))
        self.flagSelectionButton = wx.Button(self,-1,"Flag Selection",size=(160,30))
        self.flagDropButton = wx.Button(self,-1,"Drop flagged",size=(160,30))
        self.flagLoadButton = wx.Button(self,-1,"Load flags",size=(160,30))
        self.flagSaveButton = wx.Button(self,-1,"Save flags",size=(160,30))
        self.flagClearButton = wx.Button(self,-1,"Clear flags",size=(160,30)) 
Example #5
Source File: DataTypeEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def ShowHighlights(self):
        type_infos = self.Controler.GetDataTypeInfos(self.TagName)
        for infos, start, end, highlight_type in self.Highlights:
            if infos[0] == "struct":
                self.StructureElementsTable.AddHighlight(infos[1:], highlight_type)
            else:
                control = self.HighlightControls.get((type_infos["type"], infos[0]), None)
                if control is not None:
                    if isinstance(control, (wx.ComboBox, wx.SpinCtrl)):
                        control.SetBackgroundColour(highlight_type[0])
                        control.SetForegroundColour(highlight_type[1])
                    elif isinstance(control, wx.TextCtrl):
                        control.SetStyle(start[1], end[1] + 1, wx.TextAttr(highlight_type[1], highlight_type[0]))
                    elif isinstance(control, wx.gizmos.EditableListBox):
                        listctrl = control.GetListCtrl()
                        listctrl.SetItemBackgroundColour(infos[1], highlight_type[0])
                        listctrl.SetItemTextColour(infos[1], highlight_type[1])
                        listctrl.Select(listctrl.FocusedItem, False) 
Example #6
Source File: DataTypeEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def ClearHighlights(self, highlight_type=None):
        if highlight_type is None:
            self.Highlights = []
        else:
            self.Highlights = [(infos, start, end, highlight) for (infos, start, end, highlight) in self.Highlights if highlight != highlight_type]
        for control in self.HighlightControls.itervalues():
            if isinstance(control, (wx.ComboBox, wx.SpinCtrl)):
                control.SetBackgroundColour(wx.NullColour)
                control.SetForegroundColour(wx.NullColour)
            elif isinstance(control, wx.TextCtrl):
                value = control.GetValueStr() if isinstance(control, CustomIntCtrl) else \
                        control.GetValue()
                control.SetStyle(0, len(value), wx.TextAttr(wx.NullColour))
            elif isinstance(control, wx.gizmos.EditableListBox):
                listctrl = control.GetListCtrl()
                for i in xrange(listctrl.GetItemCount()):
                    listctrl.SetItemBackgroundColour(i, wx.NullColour)
                    listctrl.SetItemTextColour(i, wx.NullColour)
        self.StructureElementsTable.ClearHighlights(highlight_type)
        self.RefreshView() 
Example #7
Source File: SFCTransitionDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def GetTransitionType(self):
        """
        Return type selected for SFC transition and associated value
        @return: Type selected and associated value (None if no value)
        """
        # Go through radio buttons and return type and value associated to the
        # one that is selected
        for type, (radio, control) in self.TypeRadioButtons.iteritems():
            if radio.GetValue():
                if isinstance(control, wx.ComboBox):
                    return type, control.GetStringSelection()
                elif isinstance(control, wx.TextCtrl):
                    return type, control.GetValue()
                else:
                    return type, None
        return None, None 
Example #8
Source File: guiminer.py    From poclbm with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, title, current_language):
        style = wx.DEFAULT_DIALOG_STYLE
        vbox = wx.BoxSizer(wx.VERTICAL)
        wx.Dialog.__init__(self, parent, -1, title, style=style)
        self.lbl = wx.StaticText(self, -1,
            _("Choose language (requires restart to take full effect)"))
        vbox.Add(self.lbl, 0, wx.ALL, 10)
        self.language_choices = wx.ComboBox(self, -1,
                                            choices=sorted(LANGUAGES.keys()),
                                            style=wx.CB_READONLY)

        self.language_choices.SetStringSelection(LANGUAGES_REVERSE[current_language])

        vbox.Add(self.language_choices, 0, wx.ALL, 10)
        buttons = self.CreateButtonSizer(wx.OK | wx.CANCEL)
        vbox.Add(buttons, 0, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL, 10)
        self.SetSizerAndFit(vbox) 
Example #9
Source File: testingManualEntryPanel.py    From HH---POS-Accounting-and-ERP-Software with MIT License 6 votes vote down vote up
def __init__(self, parent):

        wx.Dialog.__init__(self, parent, wx.ID_ANY, "Manual Entry", size=(650, 600))
        self.panel = wx.Panel(self, wx.ID_ANY)

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)

        self.folios = self.fetchFolios()

        self.lblFolioD = wx.StaticText(self.panel, label="Folio (Debit)")
        self.folioComboD = wx.ComboBox(self.panel, choices=list(self.folios.keys()))

        self.mainSizer.Add(self.lblFolioD)
        self.mainSizer.Add(self.folioComboD)

        self.SetSizer(self.mainSizer)
        self.Layout()
        self.mainSizer.Fit(self.panel)
        self.Centre(wx.BOTH)

        self.Bind(wx.EVT_CLOSE, self.OnQuit)

        self.Show() 
Example #10
Source File: chronolapsegui.py    From chronolapse with MIT License 6 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: webcamConfigDialog.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE
        wx.Dialog.__init__(self, *args, **kwds)
        self.testwebcambutton = wx.Button(self, wx.ID_ANY, _("Test Webcam"))
        self.webcamtimestampcheck = wx.CheckBox(self, wx.ID_ANY, _("Show Timestamp"))
        self.label_16 = wx.StaticText(self, wx.ID_ANY, _("Format:"))
        self.webcam_timestamp_format = wx.TextCtrl(self, wx.ID_ANY, _("%Y-%m-%d %H:%M:%S"))
        self.label_9 = wx.StaticText(self, wx.ID_ANY, _("File Prefix:"))
        self.webcamprefixtext = wx.TextCtrl(self, wx.ID_ANY, _("cam_"))
        self.label_10 = wx.StaticText(self, wx.ID_ANY, _("Save Folder:"))
        self.webcamsavefoldertext = wx.TextCtrl(self, wx.ID_ANY, "")
        self.webcamsavefolderbrowse = wx.Button(self, wx.ID_ANY, _("..."))
        self.label_11 = wx.StaticText(self, wx.ID_ANY, _("File Format:"))
        self.webcamformatcombo = wx.ComboBox(self, wx.ID_ANY, choices=[_("jpg"), _("png"), _("gif")], style=wx.CB_DROPDOWN | wx.CB_DROPDOWN)
        self.webcamsavebutton = wx.Button(self, wx.ID_OK, "")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.testWebcamPressed, self.testwebcambutton)
        self.Bind(wx.EVT_BUTTON, self.webcamSaveFolderBrowse, self.webcamsavefolderbrowse)
        # end wxGlade 
Example #11
Source File: GUI_wxPython.py    From Python-GUI-Programming-Cookbook-Second-Edition with MIT License 6 votes vote down vote up
def addStaticBoxWithLabels(self):
        boxSizerH = wx.BoxSizer(wx.HORIZONTAL)
        staticBox = wx.StaticBox( self.panel, -1, "Labels within a Frame" )
        staticBoxSizerV = wx.StaticBoxSizer( staticBox, wx.VERTICAL )
        boxSizerV = wx.BoxSizer( wx.VERTICAL )
        staticText1 = wx.StaticText( self.panel, -1, " Choose a number:" )
        boxSizerV.Add( staticText1, 0, wx.ALL)
        staticText2 = wx.StaticText( self.panel, -1, "           Label 2")
        boxSizerV.Add( staticText2, 0, wx.ALL )
        #------------------------------------------------------
        staticBoxSizerV.Add( boxSizerV, 0, wx.ALL )
        boxSizerH.Add(staticBoxSizerV)
        #------------------------------------------------------
        boxSizerH.Add(wx.ComboBox(self.panel, size=(70, -1)))
        #------------------------------------------------------
        boxSizerH.Add(wx.SpinCtrl(self.panel, size=(50, -1), style=wx.BORDER_RAISED))             
        
        # Add local boxSizer to main frame
        self.statBoxSizerV.Add( boxSizerH, 1, wx.ALL )

    #---------------------------------------------------------- 
Example #12
Source File: settingsDialog.py    From Zulu with GNU Affero General Public License v3.0 5 votes vote down vote up
def __init__(self, output_window, *args, **kwds):
        # begin wxGlade: SerialDialog.__init__
        self.serial = kwds['serial']
        del kwds['serial']
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE

	self.outputwin = output_window

        wx.Dialog.__init__(self, *args, **kwds)
        self.sizer_4_staticbox = wx.StaticBox(self, -1, "port settings")
        self.label_port = wx.StaticText(self, -1, "port")
        self.combo_box_port = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
        self.label_baudrate = wx.StaticText(self, -1, "baudrate")
        self.combo_box_baudrate = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
        self.label_bytesize = wx.StaticText(self, -1, "bytesize")
        self.combo_box_bytesize = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
        self.label_parity = wx.StaticText(self, -1, "parity")
        self.combo_box_parity = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
        self.label_stopbits = wx.StaticText(self, -1, "stopbits")
        self.combo_box_stopbits = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
        self.radio_box_rtscts = wx.RadioBox(self, -1, "RTS/CTS", choices=["off", "on"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.radio_box_xonxoff = wx.RadioBox(self, -1, "xon/xoff", choices=["off", "on"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, "")
        self.button_ok = wx.Button(self, wx.ID_OK, "", style=wx.BU_RIGHT)

        self.__set_properties()
        self.__do_layout()
        self.__combo_init()

        self.Bind(wx.EVT_BUTTON, self.onButtonOk, self.button_ok)
        self.Bind(wx.EVT_BUTTON, self.onButtonCancel, self.button_cancel)
        # end wxGlade 
Example #13
Source File: ctl_adm.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def Append(self, stuff):
    """
    Append(stuff)
    
    stuff may be 
    - a dictionary 
    - a list of (key,val) tuples
    - a (key,val) tuple
    - a String
    """ 
    wid=None
    if isinstance(stuff, dict):
      for key in sorted(stuff.keys()):
        wid=self.AppendKey(key, stuff[key])
    elif isinstance(stuff, list):
      for data in stuff:
        if isinstance(data, (tuple, list)):
          wid=self.AppendKey(data[0], data[1])
        elif isinstance(data, (str,unicode)):
          wid=wx.ComboBox.Append(self, data)
          self.SetClientData(wid, None)
        else:
          logger.debug("unknown type to append to combobox: %s %s", type(data), data)
    elif isinstance(stuff, tuple):
      wid=self.AppendKey(stuff[0], stuff[1])
    elif isinstance(stuff, (str,unicode)):
      wid=wx.ComboBox.Append(self, stuff)
      self.SetClientData(wid, None)
    else:
      logger.debug("unknown type to append to combobox: %s %s", type(stuff), stuff)
    return wid 
Example #14
Source File: CellEditor.py    From bookhub with MIT License 5 votes vote down vote up
def _AutocompleteWith(self, newValue):
        """Suggest the given value by autocompleting it."""
        # GetInsertionPoint() doesn't seem reliable under linux
        insertIndex = len(self.control.GetValue())
        self.control.SetValue(newValue)
        if isinstance(self.control, wx.ComboBox):
            self.control.SetMark(insertIndex, len(newValue))
        else:
            # Seems that under linux, selecting only seems to work here if we do it
            # outside of the text event
            wx.CallAfter(self.control.SetSelection, insertIndex, len(newValue)) 
Example #15
Source File: CellEditor.py    From bookhub with MIT License 5 votes vote down vote up
def __init__(self, control, possibleValues=None):
        self.control = control
        self.lastUserEnteredString = self.control.GetValue()
        self.control.Bind(wx.EVT_TEXT, self._OnTextEvent)
        if isinstance(self.control, wx.ComboBox):
            self.possibleValues = self.control.GetStrings()
        else:
            self.possibleValues = possibleValues or []
        self.lowerCasePossibleValues = [x.lower() for x in self.possibleValues] 
Example #16
Source File: CellEditor.py    From bookhub with MIT License 5 votes vote down vote up
def MakeAutoCompleteComboBox(olv, columnIndex, maxObjectsToConsider=10000):
    """
    Return a ComboBox that lets the user choose from all existing values in this column.
    Do not call for large lists
    """
    col = olv.columns[columnIndex]
    maxObjectsToConsider = min(maxObjectsToConsider, olv.GetItemCount())
    options = set(col.GetStringValue(olv.GetObjectAt(i)) for i in range(maxObjectsToConsider))
    cb = wx.ComboBox(olv, choices=list(options),
                     style=wx.CB_DROPDOWN|wx.CB_SORT|wx.TE_PROCESS_ENTER)
    AutoCompleteHelper(cb)
    return cb


#------------------------------------------------------------------------- 
Example #17
Source File: IDEFrame.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def OnSelectAllMenu(self, event):
        control = self.FindFocus()
        if control is not None and control.GetName() == "Viewer":
            control.Parent.SelectAll()
        elif isinstance(control, wx.stc.StyledTextCtrl):
            control.SelectAll()
        elif isinstance(control, wx.TextCtrl):
            control.SetSelection(0, control.GetLastPosition())
        elif isinstance(control, wx.ComboBox):
            control.SetMark(0, control.GetLastPosition() + 1) 
Example #18
Source File: ImageProperty.py    From meerk40t with MIT License 5 votes vote down vote up
def __init__(self, *args, **kwds):
        # begin wxGlade: ImageProperty.__init__
        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE | wx.FRAME_TOOL_WINDOW | wx.STAY_ON_TOP
        wx.Frame.__init__(self, *args, **kwds)
        Module.__init__(self)
        self.SetSize((276, 218))
        self.spin_step_size = wx.SpinCtrl(self, wx.ID_ANY, "1", min=1, max=63)
        self.combo_dpi = wx.ComboBox(self, wx.ID_ANY,
                                     choices=["1000", "500", "333", "250", "200", "166", "142", "125", "111", "100"],
                                     style=wx.CB_DROPDOWN)
        self.text_x = wx.TextCtrl(self, wx.ID_ANY, "")
        self.text_y = wx.TextCtrl(self, wx.ID_ANY, "")
        self.text_width = wx.TextCtrl(self, wx.ID_ANY, "")
        self.text_height = wx.TextCtrl(self, wx.ID_ANY, "")

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_SPINCTRL, self.on_spin_step, self.spin_step_size)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_spin_step, self.spin_step_size)
        self.Bind(wx.EVT_COMBOBOX, self.on_combo_dpi, self.combo_dpi)
        self.Bind(wx.EVT_TEXT, self.on_text_x, self.text_x)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_x, self.text_x)
        self.Bind(wx.EVT_TEXT, self.on_text_y, self.text_y)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_y, self.text_y)
        self.Bind(wx.EVT_TEXT, self.on_text_width, self.text_width)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_width, self.text_width)
        self.Bind(wx.EVT_TEXT, self.on_text_height, self.text_height)
        self.Bind(wx.EVT_TEXT_ENTER, self.on_text_height, self.text_height)
        # end wxGlade
        self.image_element = None
        self.Bind(wx.EVT_CLOSE, self.on_close, self) 
Example #19
Source File: combo_box.py    From wxGlade with MIT License 5 votes vote down vote up
def create_widget(self):
        choices = [c[0] for c in self.choices]
        selection = self.selection
        self.widget = wx.ComboBox(self.parent_window.widget, self.id, choices=choices)
        self.widget.Bind(wx.EVT_SET_FOCUS, self.on_set_focus)
        self.widget.SetSelection(selection) 
Example #20
Source File: ControlProviderMixin.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def ComboBox(
        self,
        value,
        choices,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        *args,
        **kwargs
    ):
        return wx.ComboBox(
            self, -1, value, pos, size, choices, *args, **kwargs
        ) 
Example #21
Source File: new_properties.py    From wxGlade with MIT License 5 votes vote down vote up
def create_text_ctrl(self, panel, value):
        combo = wx.ComboBox( panel, -1, self.value, choices=self.choices, style=self._CB_STYLE )
        combo.SetStringSelection(self.value)
        combo.Bind(wx.EVT_COMBOBOX, self.on_combobox)
        combo.Bind(wx.EVT_KILL_FOCUS, self.on_kill_focus)
        combo.Bind(wx.EVT_SET_FOCUS, self.on_focus)
        combo.Bind(wx.EVT_CHAR, self.on_char)
        return combo 
Example #22
Source File: PouTransitionDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent):
        wx.Dialog.__init__(self, parent, title=_('Create a new transition'))

        self.TRANSITION_LANGUAGES_DICT = dict([(_(language), language)
                                               for language in GetTransitionLanguages()])

        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
        main_sizer.AddGrowableCol(0)
        main_sizer.AddGrowableRow(0)

        infos_sizer = wx.FlexGridSizer(cols=2, hgap=5, rows=3, vgap=10)
        infos_sizer.AddGrowableCol(1)
        main_sizer.AddSizer(infos_sizer, border=20,
                            flag=wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)

        transitionname_label = wx.StaticText(self, label=_('Transition Name:'))
        infos_sizer.AddWindow(transitionname_label, border=4,
                              flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP)

        self.TransitionName = wx.TextCtrl(self, size=wx.Size(180, -1))
        infos_sizer.AddWindow(self.TransitionName, flag=wx.GROW)

        language_label = wx.StaticText(self, label=_('Language:'))
        infos_sizer.AddWindow(language_label, border=4,
                              flag=wx.ALIGN_CENTER_VERTICAL | wx.TOP)

        self.Language = wx.ComboBox(self, style=wx.CB_READONLY)
        infos_sizer.AddWindow(self.Language, flag=wx.GROW)

        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
        self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
        main_sizer.AddSizer(button_sizer, border=20, flag=wx.ALIGN_RIGHT | wx.BOTTOM)

        self.SetSizer(main_sizer)

        for language in GetTransitionLanguages():
            self.Language.Append(_(language))

        self.Fit()
        self.PouNames = []
        self.PouElementNames = [] 
Example #23
Source File: color_dialog.py    From wxGlade with MIT License 5 votes vote down vote up
def __init__(self, colors_dict, parent=None):
        wx.Dialog.__init__(self, parent, -1, "")
        self.colors_dict = colors_dict
        choices = list( self.colors_dict.keys() )
        choices.sort()

        self.panel_1 = wx.Panel(self, -1)
        self.use_null_color = wx.RadioButton( self.panel_1, -1, "wxNullColour", style=wx.RB_GROUP )
        self.use_sys_color = wx.RadioButton( self.panel_1, -1, _("System Color") )
        self.sys_color = wx.ComboBox( self.panel_1, -1, choices=choices, style=wx.CB_DROPDOWN | wx.CB_READONLY)
        self.sys_color_panel = wx.Panel(self.panel_1, -1, size=(250, 20))
        self.sys_color_panel.SetBackgroundColour(wx.RED)
        self.use_chooser = wx.RadioButton(self.panel_1, -1, _("Custom Color"))
        self.color_chooser = PyColourChooser(self, -1)
        self.ok = wx.Button(self, wx.ID_OK, _("OK"))
        self.cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))

        self.__set_properties()
        self.__do_layout()

        self.use_null_color.Bind(wx.EVT_RADIOBUTTON, self.on_use_null_color)
        self.use_sys_color.Bind(wx.EVT_RADIOBUTTON, self.on_use_sys_color)
        self.use_chooser.Bind(wx.EVT_RADIOBUTTON, self.on_use_chooser)
        self.sys_color.Bind(wx.EVT_COMBOBOX, self.display_sys_color)
        self.display_sys_color()
        for ctrl in (self.use_null_color, self.use_sys_color, self.use_chooser):
            ctrl.Bind(wx.EVT_LEFT_DCLICK, lambda evt: self.EndModal(wx.ID_OK) ) 
Example #24
Source File: controlcontainer.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def _bind(self, ctlName, evt=None, proc=None):
    if isinstance(ctlName, wx.PyEventBinder): # binding to self
      ctl=super(wx.Window, self)
      proc=evt
      evt=ctlName
    elif isinstance(ctlName, wx.Window):
      ctl=ctlName
    else:
      ctl=self[ctlName]

    if not proc:
      if not isinstance(evt, wx.PyEventBinder):
        proc=evt
        evt=None
      if not proc:
        proc=self.OnCheck

    if not evt:
      if isinstance(ctl, wx.Button):
        evt=wx.EVT_BUTTON
      elif isinstance(ctl, wx.CheckBox):
        evt=wx.EVT_CHECKBOX
      elif isinstance(ctl, wx.CheckListBox):
        evt=wx.EVT_CHECKLISTBOX
      elif isinstance(ctl, wx.RadioButton):
        evt=wx.EVT_RADIOBUTTON
      else:
        evt=wx.EVT_TEXT
        if isinstance(ctl, wx.ComboBox):
          ctl.Bind(wx.EVT_COMBOBOX, proc)
    ctl.Bind(evt, proc) 
Example #25
Source File: commondialogs.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def _init_ctrls(self, prnt):
        wx.Dialog.__init__(self, id=ID_ADDSLAVEDIALOG,
              name='AddSlaveDialog', parent=prnt, pos=wx.Point(376, 223),
              size=wx.Size(300, 250), style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER,
              title=_('Add a slave to nodelist'))
        self.SetClientSize(wx.Size(300, 250))

        self.staticText1 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT1,
              label=_('Slave Name:'), name='staticText1', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)

        self.SlaveName = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENAME,
              name='SlaveName', parent=self, pos=wx.Point(0, 0), 
              size=wx.Size(0, 24), style=0)

        self.staticText2 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT2,
              label=_('Slave Node ID:'), name='staticText2', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)

        self.SlaveNodeID = wx.TextCtrl(id=ID_ADDSLAVEDIALOGSLAVENODEID,
              name='SlaveName', parent=self, pos=wx.Point(0, 0), 
              size=wx.Size(0, 24), style=wx.ALIGN_RIGHT)

        self.staticText3 = wx.StaticText(id=ID_ADDSLAVEDIALOGSTATICTEXT3,
              label=_('EDS File:'), name='staticText3', parent=self,
              pos=wx.Point(0, 0), size=wx.Size(0, 17), style=0)

        self.EDSFile = wx.ComboBox(id=ID_ADDSLAVEDIALOGEDSFILE,
              name='EDSFile', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(0, 28), style=wx.CB_READONLY)
        
        self.ImportEDS = wx.Button(id=ID_ADDSLAVEDIALOGIMPORTEDS, label=_('Import EDS'),
              name='ImportEDS', parent=self, pos=wx.Point(0, 0),
              size=wx.Size(100, 32), style=0)
        self.ImportEDS.Bind(wx.EVT_BUTTON, self.OnImportEDSButton,
              id=ID_ADDSLAVEDIALOGIMPORTEDS)
        
        self.ButtonSizer = self.CreateButtonSizer(wx.OK|wx.CANCEL|wx.CENTRE)
        self.Bind(wx.EVT_BUTTON, self.OnOK, id=self.ButtonSizer.GetAffirmativeButton().GetId())
    
        self._init_sizers() 
Example #26
Source File: ctl_adm.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def AppendKey(self, key, val):
    wid=wx.ComboBox.Append(self, val, key)
    self.keys[key] = wid
    return wid 
Example #27
Source File: ctl_adm.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def InsertKey(self, pos, key, val):
    wid=wx.ComboBox.Insert(self, val, pos, key)
    self.keys[key] = wid
    return wid 
Example #28
Source File: ctl_adm.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def __init__(self, parentWin, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
    wx.ComboBox.__init__(self, parentWin, id, "", pos, size, style=style | wx.CB_DROPDOWN|wx.CB_READONLY)
    self.keys={} 
Example #29
Source File: simplegui.py    From kicad_mmccoo with Apache License 2.0 5 votes vote down vote up
def __init__(self, parent, board):
        wx.Frame.__init__(self, parent, title="this is the title")
        self.panel = wx.Panel(self) 
        label = wx.StaticText(self.panel, label = "Hello World")
        button = wx.Button(self.panel, label="Button label", id=1)
        
        nets = board.GetNetsByName()
        self.netnames = []
        for netname, net in nets.items():
            if (str(netname) == ""):
                continue
            self.netnames.append(str(netname))
        
        netcb = wx.ComboBox(self.panel, choices=self.netnames)
        netcb.SetSelection(0)

        netsbox = wx.BoxSizer(wx.HORIZONTAL)
        netsbox.Add(wx.StaticText(self.panel, label="Nets:"))
        netsbox.Add(netcb, proportion=1)
        
        modules = board.GetModules()
        self.modulenames = []
        for mod in modules:
            self.modulenames.append("{}({})".format(mod.GetReference(), mod.GetValue()))
        modcb = wx.ComboBox(self.panel, choices=self.modulenames)
        modcb.SetSelection(0)

        modsbox = wx.BoxSizer(wx.HORIZONTAL)
        modsbox.Add(wx.StaticText(self.panel, label="Modules:"))
        modsbox.Add(modcb, proportion=1)
        
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(label,   proportion=0)
        box.Add(button,  proportion=0)
        box.Add(netsbox, proportion=0)
        box.Add(modsbox, proportion=0)
        
        self.panel.SetSizer(box)
        self.Bind(wx.EVT_BUTTON, self.OnPress, id=1)
        self.Bind(wx.EVT_COMBOBOX, self.OnSelectNet, id=netcb.GetId())
        self.Bind(wx.EVT_COMBOBOX, self.OnSelectMod, id=modcb.GetId()) 
Example #30
Source File: optionsframe.py    From youtube-dl-gui with The Unlicense 5 votes vote down vote up
def crt_combobox(self, choices, size=(-1, -1), event_handler=None):
        combobox = wx.ComboBox(self, choices=choices, size=size, style=wx.CB_READONLY)

        if event_handler is not None:
            combobox.Bind(wx.EVT_COMBOBOX, event_handler)

        return combobox