-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-v10-radio_button_box.py
More file actions
55 lines (37 loc) · 1.32 KB
/
app-v10-radio_button_box.py
File metadata and controls
55 lines (37 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
Radio Button Box
"""
import wx
class MyFrame(wx.Frame):
def __init__(self, parent, title):
super(MyFrame, self).__init__(parent, title=title, size=(600, 500))
self.SetMinSize(wx.Size(500, 400)) # ajusta tamanho minimo da janela
panel = MyPanel(self)
class MyPanel(wx.Panel):
""" Radio buttons Box """
def __init__(self, parent):
super(MyPanel, self).__init__(parent)
vbox = wx.BoxSizer(wx.VERTICAL)
# criar radio buttons box
labels = ['Cat', 'Dog', 'Rat']
self.rbox = wx.RadioBox(
self, label='Select animal', choices=labels, style=wx.RA_SPECIFY_ROWS)
# criar texto statico
self.label = wx.StaticText(self, label='')
# organizar o box sizer
vbox.Add(self.rbox, 0, wx.LEFT | wx.TOP, 50)
vbox.Add(self.label, 0, wx.LEFT, 50)
self.SetSizer(vbox)
self.Bind(wx.EVT_RADIOBOX, self.onRadioBox)
def onRadioBox(self, event):
rboxSelection = self.rbox.GetStringSelection()
self.label.SetLabelText('You have selected: ' + rboxSelection)
class MyApp(wx.App):
def OnInit(self):
title = 'Radio Box'
self.frame = MyFrame(parent=None, title=title)
self.frame.Show()
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()