【发布时间】:2011-03-09 14:13:15
【问题描述】:
我正在为我的一个项目学习 wxpython,但我遇到了一个问题.. 单击按钮后,如何存储 RadioButton 的值?
我有一个
class SerialFrame(wx.Frame):
在我里面
def __init__(self, parent, title):
super(SerialFrame, self).__init__(parent, title=title,
size=(550, 400))
self.SetMinSize(self.GetSize())
self.InitUI()
self.Center()
self.Show()
InitUI 方法设置了我的 UI,它有很多东西,包括 3 个单选按钮和一个类似的按钮
def InitUI(self):
mypanel = wx.Panel(self, -1)
...
baudRadioButton1 = wx.RadioButton(mypanel, -1, '9600', style=wx.RB_GROUP)
baudRadioButton2 = wx.RadioButton(mypanel, -1, '14400')
baudRadioButton3 = wx.RadioButton(mypanel, -1, '19200')
...
stopButton = wx.Button(mypanel, 2, label='Stop', size = (70,20))
...
mypanel.Bind(wx.EVT_BUTTON, self.clickStart, id=1)
mypanel.Bind(wx.EVT_RADIOBUTTON, self.setRadioValues, id=baudRadioButton1.GetId())
我尝试了类似的东西
def clickStart(self, event):
baudRate1 = str(self.baudRadioButton1.GetValue())
self.Close(True)
但这行不通。附言我的 OOP 知识仍然有限。
【问题讨论】:
标签: python oop user-interface wxpython