-
Notifications
You must be signed in to change notification settings - Fork 21
/
ChangePanel.py
executable file
·98 lines (69 loc) · 2.67 KB
/
ChangePanel.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env python
import wx
class Panel1(wx.Panel):
def __init__(self, parent, id):
print "Panel1 being initialized"
wx.Panel.__init__(self, parent, id)
topSizer = wx.BoxSizer(wx.VERTICAL)
header = wx.StaticText(self, -1, 'First Panel')
topSizer.Add(header, 0, wx.ALIGN_CENTER|wx.ALL, 3)
button = wx.Button(self, -1, ' Next Panel ', wx.DefaultPosition, wx.Size(-1, 32))
self.Bind(wx.EVT_BUTTON, self.Click, button)
topSizer.Add((1, 13), 0, wx.ALIGN_CENTER)
topSizer.Add(button, 0, wx.ALIGN_CENTER|wx.RIGHT|wx.LEFT, 60)
topSizer.Add((1, 13), 0, wx.ALIGN_CENTER)
footer = wx.StaticText(self, -1, 'First Panel')
topSizer.Add(footer, 0, wx.ALIGN_CENTER|wx.ALL, 3)
self.SetSizer(topSizer)
self.Fit()
def Click(self, event):
self.GetParent().ChangePanel()
class Panel2(wx.Panel):
def __init__(self, parent, id):
print "Panel2 being initialized"
wx.Panel.__init__(self, parent, id)
topSizer = wx.BoxSizer(wx.HORIZONTAL)
topSizer.Add((20, 20), 0, wx.ALIGN_CENTER|wx.ALL, 3)
leftText = wx.StaticText(self, -1, 'Second\n Panel')
topSizer.Add(leftText, 0, wx.ALIGN_CENTER|wx.ALL, 3)
button = wx.Button(self, -1, ' Next Panel ', wx.DefaultPosition, wx.Size(-1, 32))
self.Bind(wx.EVT_BUTTON, self.Click, button)
topSizer.Add((20, 20), 0, wx.ALIGN_CENTER|wx.ALL, 3)
topSizer.Add(button, 0, wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM, 33)
topSizer.Add((20, 20), 0, wx.ALIGN_CENTER|wx.ALL, 3)
rightText = wx.StaticText(self, -1, 'Second\n Panel')
topSizer.Add(rightText, 0, wx.ALIGN_CENTER|wx.ALL, 3)
topSizer.Add((20, 20), 0, wx.ALIGN_CENTER|wx.ALL, 3)
self.SetSizer(topSizer)
self.Fit()
def Click(self, event):
self.GetParent().ChangePanel()
class MyFrame(wx.Frame):
def __init__(self, parent, id):
wx.Frame.__init__(self, parent, id, 'My App')
self.panel1 = Panel1(self, -1)
self.panel2 = Panel2(self, -1)
self.currentPanel = 2
self.ChangePanel()
self.Fit()
self.Show(True)
def ChangePanel(self):
if self.currentPanel == 1:
self.currentPanel = 2
self.panel1.Hide()
self.panel2.Show()
else:
self.currentPanel = 1
self.panel2.Hide()
self.panel1.Show()
self.Fit()
class MyApp(wx.App):
def OnInit(self):
self.frame = MyFrame(None, -1)
self.SetTopWindow(self.frame)
return True
def main():
app = MyApp(0)
app.MainLoop()
if __name__ == '__main__':
main()