-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-v8-checkbox.py
More file actions
64 lines (47 loc) · 1.64 KB
/
app-v8-checkbox.py
File metadata and controls
64 lines (47 loc) · 1.64 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
56
57
58
59
60
61
62
63
64
"""
Check 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):
def __init__(self, parent):
super(MyPanel, self).__init__(parent)
vbox = wx.BoxSizer(wx.VERTICAL)
self.cb1 = wx.CheckBox(self, label='Cat')
self.cb2 = wx.CheckBox(self, label='Dog')
self.cb3 = wx.CheckBox(self, label='Rat')
self.label = wx.StaticText(self, label='')
vbox.Add(self.cb1)
vbox.Add(self.cb2)
vbox.Add(self.cb3)
vbox.Add(self.label)
self.SetSizer(vbox)
self.Bind(wx.EVT_CHECKBOX, self.onChecked)
def onChecked(self, event):
cb = event.GetEventObject()
# Desmarca os outros checkboxes = radio button
# NOTE: caso a necessidade seja marcar mais de um, entao remova esse
# trecho
# if cb == self.cb1:
# self.cb2.SetValue(False)
# self.cb3.SetValue(False)
# elif cb == self.cb2:
# self.cb1.SetValue(False)
# self.cb3.SetValue(False)
# elif cb == self.cb3:
# self.cb1.SetValue(False)
# self.cb2.SetValue(False)
self.label.SetLabelText('You have selected: ' + cb.GetLabel())
class MyApp(wx.App):
def OnInit(self):
title = 'Check Box'
self.frame = MyFrame(parent=None, title=title)
self.frame.Show()
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()