13.07.2015 Views

The wxPython tutorial

The wxPython tutorial

The wxPython tutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>wxPython</strong> widgetshttp://www.zetcode.com/wxpython/widgets/group of the first RadioButton. Declaring another RadioButton withthe wx.RB_GROUP flag will start a new radio button group.wx.RadioButton Styleswx.RB_GROUPwx.RB_SINGLEwx.CB_SORTFigure: radiobutton.py#!/usr/bin/python# radiobuttons.pyimport wxclass RadioButtons(wx.Frame):def __init__(self, parent, id, title, size=(210, 150)):wx.Frame.__init__(self, parent, id, title)panel = wx.Panel(self, -1)self.rb1 = wx.RadioButton(panel, -1, 'Value A', (10, 10), style=wx.RB_GROUPself.rb2 = wx.RadioButton(panel, -1, 'Value B', (10, 30))self.rb3 = wx.RadioButton(panel, -1, 'Value C', (10, 50))self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb1.GetId())self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb2.GetId())self.Bind(wx.EVT_RADIOBUTTON, self.SetVal, id=self.rb3.GetId())self.statusbar = self.CreateStatusBar(3)self.SetVal(True)self.Centre()self.Show(True)def SetVal(self, event):state1 = str(self.rb1.GetValue())state2 = str(self.rb2.GetValue())state3 = str(self.rb3.GetValue())self.statusbar.SetStatusText(state1, 0)self.statusbar.SetStatusText(state2, 1)self.statusbar.SetStatusText(state3, 2)app = wx.App()15 de 29 27/04/2008 1:04

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!