本文整理汇总了Python中wx.RB_GROUP属性的典型用法代码示例。如果您正苦于以下问题:Python wx.RB_GROUP属性的具体用法?Python wx.RB_GROUP怎么用?Python wx.RB_GROUP使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.RB_GROUP属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddSelector
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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: addRadioButtons
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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
示例3: createRadioButtons
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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
示例4: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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)
示例5: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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) )
示例6: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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)
示例7: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [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)
示例8: _create_custom_layout
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [as 别名]
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)
示例9: Configure
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [as 别名]
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,
)
#===============================================================================
示例10: Configure
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [as 别名]
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
)
示例11: Configure
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [as 别名]
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(),
)
示例12: __init__
# 需要导入模块: import wx [as 别名]
# 或者: from wx import RB_GROUP [as 别名]
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()