本文整理汇总了Python中wx.RadioButton方法的典型用法代码示例。如果您正苦于以下问题:Python wx.RadioButton方法的具体用法?Python wx.RadioButton怎么用?Python wx.RadioButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wx
的用法示例。
在下文中一共展示了wx.RadioButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddSelector
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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)
示例2: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
def __init__(self, name, parent, index, style, label, choices, major_dim):
"Class to handle wxRadioBox objects"
ManagedBase.__init__(self, name, parent, index)
self.static_box = None
# initialise instance properties
self.label = np.TextProperty("", multiline="grow")
self.dimension = np.SpinProperty(major_dim)
self.selection = np.SpinProperty(0, val_range=(0,len(choices)-1), immediate=True )
self.choices = ChoicesProperty( choices, [(_('Label'), np.GridProperty.STRING)] )
style = style or wx.RA_SPECIFY_ROWS
styles = [wx.RA_SPECIFY_ROWS, wx.RA_SPECIFY_COLS]
aliases = ["wxRA_SPECIFY_ROWS","wxRA_SPECIFY_COLS"] # labels and aliases
self.style = np.RadioProperty(style, styles, aliases, aliases=aliases, columns=2)
self.buttons = None # list of wx.RadioButton
# widget creation / updates ########################################################################################
示例3: do_layout
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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
示例4: addRadioButtons
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
def addRadioButtons(self):
boxSizerH = wx.BoxSizer(wx.HORIZONTAL)
boxSizerH.Add((2, 0))
boxSizerH.Add(wx.RadioButton(self.panel, -1, 'Blue', style=wx.RB_GROUP))
boxSizerH.Add((33, 0))
boxSizerH.Add(wx.RadioButton(self.panel, -1, 'Gold'))
boxSizerH.Add((45, 0))
boxSizerH.Add(wx.RadioButton(self.panel, -1, 'Red' ))
self.statBoxSizerV.Add(boxSizerH, 0, wx.ALL, 8)
#----------------------------------------------------------
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:13,代码来源:GUI_wxPython.py
示例5: do_layout
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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
示例6: createRadioButtons
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
def createRadioButtons(self):
# button groups in wx are statefully determined via a style flag
# on the first button (what???). All button instances are part of the
# same group until a new button is created with the style flag RG_GROUP
# https://wxpython.org/Phoenix/docs/html/wx.RadioButton.html
# (What???)
firstButton = wx.RadioButton(self, style=wx.RB_GROUP)
firstButton.SetValue(False)
buttons = [firstButton]
for _ in getin(self.widgetInfo, ['data','widgets'], [])[1:]:
buttons.append(wx.RadioButton(self))
return buttons
示例7: Add
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
def Add(self, w):
w.Reparent(self.scrolled)
self.scrollsizer.Add(w)
if (isinstance(w, wx.CheckBox) or isinstance(w, wx.RadioButton)):
self.boxes.append(w)
示例8: SendSelectorEvent
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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)
示例9: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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)
示例10: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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)
示例11: _bind
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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)
示例12: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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) )
示例13: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
def __init__(self, parent, ID, label, initval):
wx.Panel.__init__(self, parent, ID)
self.value = initval
box = wx.StaticBox(self, -1, label)
sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
self.radio_auto = wx.RadioButton(self, -1,
label="Auto", style=wx.RB_GROUP)
self.radio_manual = wx.RadioButton(self, -1,
label="Manual")
self.manual_text = wx.TextCtrl(self, -1,
size=(35,-1),
value=str(initval),
style=wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_UPDATE_UI, self.on_update_manual_text, self.manual_text)
self.Bind(wx.EVT_TEXT_ENTER, self.on_text_enter, self.manual_text)
manual_box = wx.BoxSizer(wx.HORIZONTAL)
manual_box.Add(self.radio_manual, flag=wx.ALIGN_CENTER_VERTICAL)
manual_box.Add(self.manual_text, flag=wx.ALIGN_CENTER_VERTICAL)
sizer.Add(self.radio_auto, 0, wx.ALL, 10)
sizer.Add(manual_box, 0, wx.ALL, 10)
self.SetSizer(sizer)
sizer.Fit(self)
示例14: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
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)
示例15: RadioButton
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RadioButton [as 别名]
def RadioButton(self, value, label="", *args, **kwargs):
ctrl = wx.RadioButton(self, -1, label, *args, **kwargs)
ctrl.SetValue(value)
return ctrl