Python wx.EVT_RADIOBUTTON Examples

The following are 19 code examples of wx.EVT_RADIOBUTTON(). 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: DialogUtils.py    From kicad_mmccoo with Apache License 2.0 6 votes vote down vote up
def AddSelector(self, name, binding=None):
        if (binding == None):
            binding = self.OnButton

        if (not self.singleton):
            rb = wx.CheckBox(self, label=name)
            rb.Bind(wx.EVT_CHECKBOX, binding)
        elif (len(self.boxes) == 0):
            # boxes gets updated in Add
            rb = wx.RadioButton(self.scrolled, label=name, style=wx.RB_GROUP)
            rb.Bind(wx.EVT_RADIOBUTTON, binding)
            self.SendSelectorEvent(rb)
        else:
            rb = wx.RadioButton(self.scrolled, label=name)
            rb.Bind(wx.EVT_RADIOBUTTON, binding)

        self.Add(rb) 
Example #2
Source File: params.py    From admin4 with Apache License 2.0 6 votes vote down vote up
def __init__(self, parent, name):
        pre = wx.PrePanel()
        g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP')
        self.PostCreate(pre)
        self.modified = self.freeze = False
        self.radio_std = xrc.XRCCTRL(self, 'RADIO_STD')
        self.radio_file = xrc.XRCCTRL(self, 'RADIO_FILE')
        self.combo = xrc.XRCCTRL(self, 'COMBO_STD')
        self.text = xrc.XRCCTRL(self, 'TEXT_FILE')
        self.button = xrc.XRCCTRL(self, 'BUTTON_BROWSE')
        self.textModified = False
        self.SetAutoLayout(True)
        self.GetSizer().SetMinSize((260, -1))
        self.GetSizer().Fit(self)
        wx.EVT_RADIOBUTTON(self, xrc.XRCID('RADIO_STD'), self.OnRadioStd)
        wx.EVT_RADIOBUTTON(self, xrc.XRCID('RADIO_FILE'), self.OnRadioFile)
        wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_BROWSE'), self.OnButtonBrowse)
        wx.EVT_COMBOBOX(self, xrc.XRCID('COMBO_STD'), self.OnCombo)
        wx.EVT_TEXT(self, xrc.XRCID('COMBO_STD'), self.OnChange)
        wx.EVT_TEXT(self, xrc.XRCID('TEXT_FILE'), self.OnChange) 
Example #3
Source File: components.py    From pyFileFixity with MIT License 5 votes vote down vote up
def do_layout(self, parent):
    self.panel = wx.Panel(parent)

    self.radio_buttons = [wx.RadioButton(self.panel, -1) for _ in self.data]
    self.btn_names = [wx.StaticText(self.panel, label=btn_data['display_name'].title()) for btn_data in self.data]
    self.help_msgs = [wx.StaticText(self.panel, label=btn_data['help'].title()) for btn_data in self.data]
    self.option_stings = [btn_data['commands'] for btn_data in self.data]

    # box = wx.StaticBox(self.panel, -1, label=self.data['group_name'])
    box = wx.StaticBox(self.panel, -1, label='Set Verbosity Level')
    vertical_container = wx.StaticBoxSizer(box, wx.VERTICAL)

    for button, name, help in zip(self.radio_buttons, self.btn_names, self.help_msgs):

      hbox = wx.BoxSizer(wx.HORIZONTAL)

      hbox.Add(button, 0, wx.ALIGN_TOP | wx.ALIGN_LEFT)
      hbox.Add(name, 0, wx.LEFT, 10)

      vertical_container.Add(hbox, 0, wx.EXPAND)

      vertical_container.Add(help, 1, wx.EXPAND | wx.LEFT, 25)
      vertical_container.AddSpacer(5)
      # self.panel.Bind(wx.EVT_RADIOBUTTON, self.onSetter, button)

    self.panel.SetSizer(vertical_container)
    self.panel.Bind(wx.EVT_SIZE, self.onResize)
    return self.panel 
Example #4
Source File: ConfigPanel.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def FinishSetup(self):
        self.shown = True
        if self.lines:
            self.AddGrid(self.lines, *self.sizerProps)
        spaceSizer = wx.BoxSizer(wx.HORIZONTAL)
        spaceSizer.Add((2, 2))
        spaceSizer.Add(self.sizer, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 3)
        spaceSizer.Add((4, 4))
        self.SetSizerAndFit(spaceSizer)

        #self.dialog.FinishSetup()
        def OnEvent(dummyEvent):
            self.SetIsDirty()
        self.Bind(wx.EVT_CHECKBOX, OnEvent)
        self.Bind(wx.EVT_BUTTON, OnEvent)
        self.Bind(wx.EVT_CHOICE, OnEvent)
        self.Bind(wx.EVT_TOGGLEBUTTON, OnEvent)
        self.Bind(wx.EVT_TEXT, OnEvent)
        self.Bind(wx.EVT_RADIOBOX, OnEvent)
        self.Bind(wx.EVT_RADIOBUTTON, OnEvent)
        self.Bind(wx.EVT_TREE_SEL_CHANGED, OnEvent)
        self.Bind(wx.EVT_DATE_CHANGED, OnEvent)
        self.Bind(eg.EVT_VALUE_CHANGED, OnEvent)
        self.Bind(wx.EVT_CHECKLISTBOX, OnEvent)
        self.Bind(wx.EVT_SCROLL, OnEvent)
        self.Bind(wx.EVT_LISTBOX, OnEvent) 
Example #5
Source File: RadioBox.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(
        self,
        parent = None,
        id = -1,
        label = "",
        pos = (-1, -1),
        size = (-1, -1),
        choices = (),
        majorDimension = 0,
        style = wx.RA_SPECIFY_COLS,
        validator = wx.DefaultValidator,
        name = "radioBox"
    ):
        self.value = 0
        wx.Panel.__init__(self, parent, id, pos, size, name=name)
        sizer = self.sizer = wx.GridSizer(len(choices), 1, 6, 6)
        style = wx.RB_GROUP
        for i, choice in enumerate(choices):
            radioButton = wx.RadioButton(self, i, choice, style=style)
            style = 0
            self.sizer.Add(radioButton, 0, wx.EXPAND)
            radioButton.Bind(wx.EVT_RADIOBUTTON, self.OnSelect)

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.Layout()
        self.SetMinSize(self.GetSize())
        self.Bind(wx.EVT_SIZE, self.OnSize) 
Example #6
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 #7
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 #8
Source File: params.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def __init__(self, parent, id, choices,
                 pos=wx.DefaultPosition, name='radiobox'):
        PPanel.__init__(self, parent, name)
        self.choices = choices
        topSizer = wx.BoxSizer()
        for i in choices:
            button = wx.RadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i)
            topSizer.Add(button, 0, wx.RIGHT, 5)
            wx.EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice)
        self.SetAutoLayout(True)
        self.SetSizerAndFit(topSizer) 
Example #9
Source File: DialogUtils.py    From kicad_mmccoo with Apache License 2.0 5 votes vote down vote up
def __init__(self, parent, layers=None, cols=4):
        wx.Window.__init__(self, parent, wx.ID_ANY)

        if (layers == None):
            layers = ['F.Cu', 'F.Silks','Edge.Cuts', 'F.Mask',
                      'B.Cu', 'B.SilkS','Cmts.User', 'B.Mask']

        sizer = wx.GridSizer(cols=cols)#, hgap=5, vgap=5)
        self.SetSizer(sizer)

        board = pcbnew.GetBoard()
        self.layertable = {}
        numlayers = pcbnew.PCB_LAYER_ID_COUNT
        for i in range(numlayers):
            self.layertable[board.GetLayerName(i)] = i

        for layername in layers:
            if (layername not in self.layertable):
                ValueError("layer {} doesn't exist".format(layername))

            if (layername == layers[0]):
                rb = wx.RadioButton(self, label=layername, style=wx.RB_GROUP)
                self.value = layername
                self.valueint = self.layertable[layername]
            else:
                rb = wx.RadioButton(self, label=layername)
            rb.Bind(wx.EVT_RADIOBUTTON, self.OnButton)
            sizer.Add(rb) 
Example #10
Source File: DialogUtils.py    From kicad_mmccoo with Apache License 2.0 5 votes vote down vote up
def SendSelectorEvent(self, box):
        if (isinstance(box, wx.CheckBox)):
            # I have the feeling that this is the wrong way to trigger
            # an event.
            newevent = wx.CommandEvent(wx.EVT_CHECKBOX.evtType[0])
            newevent.SetEventObject(box)
            wx.PostEvent(box, newevent)

        if (isinstance(box, wx.RadioButton)):
            newevent = wx.CommandEvent(wx.EVT_RADIOBUTTON.evtType[0])
            newevent.SetEventObject(box)
            wx.PostEvent(box, newevent) 
Example #11
Source File: app.py    From thotkeeper with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _FileDiaryOptionsMenu(self, event):
        # Grab the controls
        author_name_box = self.frame.FindWindowById(self.author_name_id)
        author_global_radio = self.frame.FindWindowById(self.author_global_id)
        author_per_entry_radio = \
            self.frame.FindWindowById(self.author_per_entry_id)

        # Enable/disable the author name box
        def _ChooseAuthorGlobal(event2):
            author_name_box.Enable(True)
        self.Bind(wx.EVT_RADIOBUTTON, _ChooseAuthorGlobal,
                  id=self.author_global_id)

        def _ChooseAuthorPerEntry(event2):
            author_name_box.Enable(False)
        self.Bind(wx.EVT_RADIOBUTTON, _ChooseAuthorPerEntry,
                  id=self.author_per_entry_id)

        # Set the controls to the current settings
        author_name = self.entries.get_author_name()
        if author_name is None:
            author_name_box.SetValue("")
        else:
            author_name_box.SetValue(author_name)
        if (self.entries.get_author_global()):
            author_name_box.Enable(True)
            author_global_radio.SetValue(True)
        else:
            author_name_box.Enable(False)
            author_per_entry_radio.SetValue(True)
        if (self.diary_options_dialog.ShowModal() == wx.ID_OK):
            # Save the settings if OK pressed
            if (author_name_box.GetValue() == ""):
                self.entries.set_author_name(None)
            else:
                self.entries.set_author_name(author_name_box.GetValue())
            self.entries.set_author_global(author_global_radio.GetValue())
            self._UpdateAuthorBox()  # Show/Hide the author box as needed
            self._SetDiaryModified(True) 
Example #12
Source File: components2.py    From pyFileFixity with MIT License 5 votes vote down vote up
def do_layout(self, parent):
    self.panel = wx.Panel(parent)

    self.radio_buttons = [wx.RadioButton(self.panel, -1) for _ in self.data]
    self.btn_names = [wx.StaticText(self.panel, label=btn_data['display_name'].title()) for btn_data in self.data]
    self.help_msgs = [wx.StaticText(self.panel, label=btn_data['help'].title()) for btn_data in self.data]
    self.option_stings = [btn_data['commands'] for btn_data in self.data]

    # box = wx.StaticBox(self.panel, -1, label=self.data['group_name'])
    box = wx.StaticBox(self.panel, -1, label='Set Verbosity Level')
    vertical_container = wx.StaticBoxSizer(box, wx.VERTICAL)

    for button, name, help in zip(self.radio_buttons, self.btn_names, self.help_msgs):

      hbox = wx.BoxSizer(wx.HORIZONTAL)

      hbox.Add(button, 0, wx.ALIGN_TOP | wx.ALIGN_LEFT)
      hbox.Add(name, 0, wx.LEFT, 10)

      vertical_container.Add(hbox, 0, wx.EXPAND)

      vertical_container.Add(help, 1, wx.EXPAND | wx.LEFT, 25)
      vertical_container.AddSpacer(5)
      # self.panel.Bind(wx.EVT_RADIOBUTTON, self.onSetter, button)

    self.panel.SetSizer(vertical_container)
    self.panel.Bind(wx.EVT_SIZE, self.onResize)
    return self.panel 
Example #13
Source File: components.py    From me-ica with GNU Lesser General Public License v2.1 5 votes vote down vote up
def do_layout(self, parent, titles, msgs):
    self.panel = wx.Panel(parent)

    self.radio_buttons = [wx.RadioButton(self.panel, -1) for _ in titles]
    self.btn_names = [wx.StaticText(self.panel, label=title.title()) for title in titles]
    self.help_msgs = [wx.StaticText(self.panel, label=msg.title()) for msg in msgs]

    # box = wx.StaticBox(self.panel, -1, label=self.data['group_name'])
    box = wx.StaticBox(self.panel, -1, label='')
    vertical_container = wx.StaticBoxSizer(box, wx.VERTICAL)

    for button, name, help in zip(self.radio_buttons, self.btn_names, self.help_msgs):

      hbox = wx.BoxSizer(wx.HORIZONTAL)

      hbox.Add(button, 0, wx.ALIGN_TOP | wx.ALIGN_LEFT)
      hbox.Add(name, 0, wx.LEFT, 10)

      vertical_container.Add(hbox, 0, wx.EXPAND)

      vertical_container.Add(help, 1, wx.EXPAND | wx.LEFT, 25)
      vertical_container.AddSpacer(5)

    self.panel.SetSizer(vertical_container)
    self.panel.Bind(wx.EVT_SIZE, self.onResize)
    self.panel.Bind(wx.EVT_RADIOBUTTON, self.showz)
    return self.panel 
Example #14
Source File: chapter7.py    From opencv-python-blueprints with GNU General Public License v3.0 4 votes vote down vote up
def _create_custom_layout(self):
        """Decorates the GUI with buttons for assigning class labels"""
        # create horizontal layout with train/test buttons
        pnl1 = wx.Panel(self, -1)
        self.training = wx.RadioButton(pnl1, -1, 'Train', (10, 10),
                                       style=wx.RB_GROUP)
        self.Bind(wx.EVT_RADIOBUTTON, self._on_training, self.training)
        self.testing = wx.RadioButton(pnl1, -1, 'Test')
        self.Bind(wx.EVT_RADIOBUTTON, self._on_testing, self.testing)
        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        hbox1.Add(self.training, 1)
        hbox1.Add(self.testing, 1)
        pnl1.SetSizer(hbox1)

        # create a horizontal layout with all buttons
        pnl2 = wx.Panel(self, -1)
        self.neutral = wx.RadioButton(pnl2, -1, 'neutral', (10, 10),
                                      style=wx.RB_GROUP)
        self.happy = wx.RadioButton(pnl2, -1, 'happy')
        self.sad = wx.RadioButton(pnl2, -1, 'sad')
        self.surprised = wx.RadioButton(pnl2, -1, 'surprised')
        self.angry = wx.RadioButton(pnl2, -1, 'angry')
        self.disgusted = wx.RadioButton(pnl2, -1, 'disgusted')
        hbox2 = wx.BoxSizer(wx.HORIZONTAL)
        hbox2.Add(self.neutral, 1)
        hbox2.Add(self.happy, 1)
        hbox2.Add(self.sad, 1)
        hbox2.Add(self.surprised, 1)
        hbox2.Add(self.angry, 1)
        hbox2.Add(self.disgusted, 1)
        pnl2.SetSizer(hbox2)

        # create horizontal layout with single snapshot button
        pnl3 = wx.Panel(self, -1)
        self.snapshot = wx.Button(pnl3, -1, 'Take Snapshot')
        self.Bind(wx.EVT_BUTTON, self._on_snapshot, self.snapshot)
        hbox3 = wx.BoxSizer(wx.HORIZONTAL)
        hbox3.Add(self.snapshot, 1)
        pnl3.SetSizer(hbox3)

        # arrange all horizontal layouts vertically
        self.panels_vertical.Add(pnl1, flag=wx.EXPAND | wx.TOP, border=1)
        self.panels_vertical.Add(pnl2, flag=wx.EXPAND | wx.BOTTOM, border=1)
        self.panels_vertical.Add(pnl3, flag=wx.EXPAND | wx.BOTTOM, border=1) 
Example #15
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 4 votes vote down vote up
def Configure(self, mode = 0, state = 0):
        self.stt = state
        panel=eg.ConfigPanel(self)
        topSizer = wx.StaticBoxSizer(
            wx.StaticBox(panel, -1, self.text.rbLabel),
            wx.VERTICAL
        )
        boolSizer = wx.BoxSizer(wx.HORIZONTAL)
        rb0 = panel.RadioButton(mode==0, self.text.numVal, style=wx.RB_GROUP)
        rb1 = panel.RadioButton(mode==1, self.text.strVal)
        rb2 = panel.RadioButton(mode==2, self.text.boolVal)
        statChoice = wx.Choice(panel, -1, choices = self.text.states)
        statChoice.Select(state)
        boolSizer.Add(rb2,0,wx.TOP,3)
        boolSizer.Add(statChoice)
        topSizer.Add(rb0,0,wx.TOP,3)
        topSizer.Add(rb1,0,wx.TOP,7)
        topSizer.Add(boolSizer,0,wx.TOP,5)
        panel.sizer.Add(topSizer)


        def onState(evt):
            self.stt = evt.GetSelection()
            evt.Skip()
        statChoice.Bind(wx.EVT_CHOICE, onState)

        def onRadio(evt = None):
            flg = rb2.GetValue()
            statChoice.Enable(flg)
            sel = self.stt if flg else -1
            statChoice.SetSelection(sel)
            if evt:
                evt.Skip()
        rb0.Bind(wx.EVT_RADIOBUTTON, onRadio)
        rb1.Bind(wx.EVT_RADIOBUTTON, onRadio)
        rb2.Bind(wx.EVT_RADIOBUTTON, onRadio)
        onRadio()

        while panel.Affirmed():
            state = state if self.stt == -1 else self.stt
            panel.SetResult(
                (rb0.GetValue(),rb1.GetValue(),rb2.GetValue()).index(True),
                state,
            )
#=============================================================================== 
Example #16
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 4 votes vote down vote up
def Configure(self, count=None, timeout=1.0):
        text = self.text
        panel = eg.ConfigPanel()
        if count is None:
            count = 1
            flag = False
        else:
            flag = True
        if timeout is None:
            timeout = 1.0
        rb1 = panel.RadioButton(not flag, text.read_all, style=wx.RB_GROUP)
        rb2 = panel.RadioButton(flag, text.read_some)
        countCtrl = panel.SpinIntCtrl(count, 1, 1024)
        countCtrl.Enable(flag)
        timeCtrl = panel.SpinIntCtrl(int(timeout * 1000), 0, 10000)
        timeCtrl.Enable(flag)

        def OnRadioButton(event):
            flag = rb2.GetValue()
            countCtrl.Enable(flag)
            timeCtrl.Enable(flag)
            event.Skip()
        rb1.Bind(wx.EVT_RADIOBUTTON, OnRadioButton)
        rb2.Bind(wx.EVT_RADIOBUTTON, OnRadioButton)

        Add = panel.sizer.Add
        Add(rb1)
        Add((5,5))
        Add(rb2)
        Add((5,5))
        Add(countCtrl, 0, wx.LEFT, 25)
        Add((5,5))
        Add(panel.StaticText(text.read_time), 0, wx.LEFT, 25)
        Add((5,5))
        Add(timeCtrl, 0, wx.LEFT, 25)

        while panel.Affirmed():
            if rb1.GetValue():
                panel.SetResult(None, 0.0)
            else:
                panel.SetResult(
                    countCtrl.GetValue(),
                    timeCtrl.GetValue() / 1000.0
                ) 
Example #17
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 4 votes vote down vote up
def Configure(self, value="60", unit = 0, pos = 0, dir = 0):
        text = self.text
        panel = eg.ConfigPanel()
        mySizer = panel.sizer
        width = 120
        staticText = panel.StaticText(text.label)
        textCtrl = panel.TextCtrl(value, size = (2*width+10,-1))
        unitSizer = wx.StaticBoxSizer(
            wx.StaticBox(panel, -1, text.unit),
            wx.HORIZONTAL
        )
        rb1 = panel.RadioButton(not unit, text.unitChoice[0], style=wx.RB_GROUP, size = (width,-1))
        rb2 = panel.RadioButton(unit, text.unitChoice[1])
        unitSizer.Add(rb1, 1)
        unitSizer.Add(rb2, 1)

        posSizer = wx.StaticBoxSizer(
            wx.StaticBox(panel, -1, text.pos),
            wx.HORIZONTAL
        )
        rb3 = panel.RadioButton(not pos, text.posChoice[0], style=wx.RB_GROUP, size = (width,-1))
        rb4 = panel.RadioButton(pos, text.posChoice[1])
        posSizer.Add(rb3, 1)
        posSizer.Add(rb4, 1)

        dirSizer = wx.StaticBoxSizer(
            wx.StaticBox(panel, -1, text.dir),
            wx.HORIZONTAL
        )
        rb5 = panel.RadioButton(not dir, text.dirChoice[0], style=wx.RB_GROUP, size = (width,-1))
        rb6 = panel.RadioButton(dir, text.dirChoice[1])
        dirSizer.Add(rb5, 1)
        dirSizer.Add(rb6, 1)

        def OnRadioButton(event=None):
            flag = rb3.GetValue()
            mySizer.Show(dirSizer,flag,True)
            mySizer.Layout()
            if event:
                event.Skip()
        rb3.Bind(wx.EVT_RADIOBUTTON, OnRadioButton)
        rb4.Bind(wx.EVT_RADIOBUTTON, OnRadioButton)

        mySizer.Add(staticText, 0, wx.TOP, 5)
        mySizer.Add(textCtrl, 0, wx.TOP, 2)
        mySizer.Add(unitSizer, 0, wx.TOP, 15)
        mySizer.Add(posSizer, 0, wx.TOP, 15)
        mySizer.Add(dirSizer, 0, wx.TOP, 15)
        OnRadioButton()
        while panel.Affirmed():
            panel.SetResult(
                textCtrl.GetValue(),
                rb2.GetValue(),
                rb4.GetValue(),
                rb6.GetValue(),
                ) 
Example #18
Source File: LDPowerRailDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent, controller, tagname):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param controller: Reference to project controller
        @param tagname: Tagname of project POU edited
        """
        BlockPreviewDialog.__init__(self, parent, controller, tagname,
                                    title=_('Power Rail Properties'))

        # Init common sizers
        self._init_sizers(2, 0, 5, None, 2, 1)

        # Create label for connection type
        type_label = wx.StaticText(self, label=_('Type:'))
        self.LeftGridSizer.AddWindow(type_label, flag=wx.GROW)

        # Create radio buttons for selecting power rail type
        self.TypeRadioButtons = {}
        first = True
        for type, label in [(LEFTRAIL, _('Left PowerRail')),
                            (RIGHTRAIL, _('Right PowerRail'))]:
            radio_button = wx.RadioButton(self, label=label,
                                          style=(wx.RB_GROUP if first else 0))
            radio_button.SetValue(first)
            self.Bind(wx.EVT_RADIOBUTTON, self.OnTypeChanged, radio_button)
            self.LeftGridSizer.AddWindow(radio_button, flag=wx.GROW)
            self.TypeRadioButtons[type] = radio_button
            first = False

        # Create label for power rail pin number
        pin_number_label = wx.StaticText(self, label=_('Pin number:'))
        self.LeftGridSizer.AddWindow(pin_number_label, flag=wx.GROW)

        # Create spin control for defining power rail pin number
        self.PinNumber = wx.SpinCtrl(self, min=1, max=50,
                                     style=wx.SP_ARROW_KEYS)
        self.PinNumber.SetValue(1)
        self.Bind(wx.EVT_SPINCTRL, self.OnPinNumberChanged, self.PinNumber)
        self.LeftGridSizer.AddWindow(self.PinNumber, flag=wx.GROW)

        # Add preview panel and associated label to sizers
        self.RightGridSizer.AddWindow(self.PreviewLabel, flag=wx.GROW)
        self.RightGridSizer.AddWindow(self.Preview, flag=wx.GROW)

        # Add buttons sizer to sizers
        self.MainSizer.AddSizer(
            self.ButtonSizer, border=20,
            flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)
        self.Fit()

        # Left Power Rail radio button is default control having keyboard focus
        self.TypeRadioButtons[LEFTRAIL].SetFocus() 
Example #19
Source File: viewer_low_level_util.py    From dials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, outer_panel):
        super(buttons_panel, self).__init__(outer_panel)
        self.parent_panel = outer_panel

        Show_Its_CheckBox = wx.CheckBox(self, -1, "Show I nums")
        Show_Its_CheckBox.SetValue(True)
        Show_Its_CheckBox.Bind(wx.EVT_CHECKBOX, self.OnItsCheckbox)

        self.my_sizer = wx.BoxSizer(wx.VERTICAL)
        self.my_sizer.Add(Show_Its_CheckBox, proportion=0, flag=wx.ALIGN_TOP, border=5)

        if self.parent_panel.segn_lst_in is not None:
            Show_Msk_CheckBox = wx.CheckBox(self, -1, "Show Mask")
            Show_Msk_CheckBox.SetValue(True)
            Show_Msk_CheckBox.Bind(wx.EVT_CHECKBOX, self.OnMskCheckbox)

            self.my_sizer.Add(
                Show_Msk_CheckBox, proportion=0, flag=wx.ALIGN_TOP, border=5
            )

            masck_conv_str = "\n Mask Convention:"
            masck_conv_str += "\n [Valid]                      =  \\\\\\\\\\\\  "
            masck_conv_str += "\n [Foreground]           =  //////  "
            masck_conv_str += "\n [Background]          =  ||||||  "
            masck_conv_str += "\n [BackgroundUsed]  =  ------"

            label_mask = wx.StaticText(self, -1, masck_conv_str)
            self.my_sizer.Add(label_mask, proportion=0, flag=wx.ALIGN_TOP, border=5)

        label_palette = wx.StaticText(self, -1, "\nColour Palettes")

        self.RadButtb2w = wx.RadioButton(self, -1, "black2white")
        self.RadButtw2b = wx.RadioButton(self, -1, "white2black")
        self.RadButtha = wx.RadioButton(self, -1, "hot ascend")
        self.RadButthd = wx.RadioButton(self, -1, "hot descend")

        self.RadButtb2w.Bind(wx.EVT_RADIOBUTTON, self.OnButtb2w)
        self.RadButtw2b.Bind(wx.EVT_RADIOBUTTON, self.OnButtw2b)
        self.RadButtha.Bind(wx.EVT_RADIOBUTTON, self.OnButtha)
        self.RadButthd.Bind(wx.EVT_RADIOBUTTON, self.OnButthd)

        self.my_sizer.Add(label_palette, proportion=0, flag=wx.ALIGN_TOP, border=5)

        self.my_sizer.Add(self.RadButtb2w, proportion=0, flag=wx.ALIGN_TOP, border=5)
        self.my_sizer.Add(self.RadButtw2b, proportion=0, flag=wx.ALIGN_TOP, border=5)
        self.my_sizer.Add(self.RadButtha, proportion=0, flag=wx.ALIGN_TOP, border=5)
        self.my_sizer.Add(self.RadButthd, proportion=0, flag=wx.ALIGN_TOP, border=5)

        self.my_sizer.SetMinSize((50, 300))
        self.SetSizer(self.my_sizer)