-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp-v12-message_box.py
More file actions
68 lines (50 loc) · 1.97 KB
/
app-v12-message_box.py
File metadata and controls
68 lines (50 loc) · 1.97 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
65
66
67
68
"""
Message 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)
# criar layouts
vbox = wx.BoxSizer(wx.VERTICAL)
widgetPanel = wx.Panel(self)
widgetSizer = wx.BoxSizer(wx.VERTICAL)
# criar widgets
self.button = wx.Button(widgetPanel, label='Open Message (Info)')
self.button2 = wx.Button(widgetPanel, label='Open Message (Warning)')
self.button3 = wx.Button(widgetPanel, label='Open Message (Error)')
# organizar widgets no layout
widgetSizer.Add(self.button)
widgetSizer.Add(self.button2, 0, wx.TOP, 10)
widgetSizer.Add(self.button3, 0, wx.TOP, 10)
widgetPanel.SetSizer(widgetSizer)
vbox.Add(widgetPanel, 0, wx.LEFT | wx.TOP, 100)
self.SetSizer(vbox)
# add eventos aos widgets
self.Bind(wx.EVT_BUTTON, self.MessageBox.Info, self.button)
self.Bind(wx.EVT_BUTTON, self.MessageBox.Warn, self.button2)
self.Bind(wx.EVT_BUTTON, self.MessageBox.Error, self.button3)
class MessageBox:
def Info(self):
wx.MessageBox('Message box Info icon', 'Dialog',
wx.OK | wx.ICON_INFORMATION)
def Warn(self):
wx.MessageBox('Message box Warning icon',
'Dialog', wx.OK | wx.ICON_WARNING)
def Error(self):
wx.MessageBox('Message box Error icon',
'Dialog', wx.OK | wx.ICON_ERROR)
class MyApp(wx.App):
def OnInit(self):
title = 'Message Box'
self.frame = MyFrame(parent=None, title=title)
self.frame.Show()
return True
if __name__ == '__main__':
app = MyApp()
app.MainLoop()