]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxWizard.py
Font updates
[wxWidgets.git] / wxPython / demo / wxWizard.py
1
2 from wxPython.wx import *
3 from wxPython.wizard import *
4
5 import images
6
7 #----------------------------------------------------------------------
8
9 class TitledPage(wxWizardPageSimple):
10 def __init__(self, parent, title):
11 wxWizardPageSimple.__init__(self, parent)
12 self.sizer = sizer = wxBoxSizer(wxVERTICAL)
13 self.SetSizer(sizer)
14
15 title = wxStaticText(self, -1, title)
16 title.SetFont(wxFont(18, wxSWISS, wxNORMAL, wxBOLD))
17 sizer.AddWindow(title, 0, wxALIGN_CENTRE|wxALL, 5)
18 sizer.AddWindow(wxStaticLine(self, -1), 0, wxEXPAND|wxALL, 5)
19
20
21
22 #----------------------------------------------------------------------
23
24
25 #----------------------------------------------------------------------
26
27 class TestPanel(wxPanel):
28 ID_wiz = wxNewId()
29
30 def __init__(self, parent, log):
31 self.log = log
32 wxPanel.__init__(self, parent, -1)
33
34 b = wxButton(self, -1, "Run Simple Wizard", pos=(50, 50))
35 EVT_BUTTON(self, b.GetId(), self.OnRunSimpleWizard)
36
37 b = wxButton(self, -1, "Run Dynamic Wizard", pos=(50, 100))
38 EVT_BUTTON(self, b.GetId(), self.OnRunDynamicWizard)
39
40 EVT_WIZARD_PAGE_CHANGED(self, self.ID_wiz, self.OnWizPageChanged)
41 EVT_WIZARD_PAGE_CHANGING(self, self.ID_wiz, self.OnWizPageChanging)
42 EVT_WIZARD_CANCEL(self, self.ID_wiz, self.OnWizCancel)
43
44
45 def OnWizPageChanged(self, evt):
46 if evt.GetDirection():
47 dir = "forward"
48 else:
49 dir = "backward"
50 page = evt.GetPage()
51 self.log.write("OnWizPageChanged: %s, %s\n" % (dir, page.__class__))
52
53
54 def OnWizPageChanging(self, evt):
55 if evt.GetDirection():
56 dir = "forward"
57 else:
58 dir = "backward"
59 page = evt.GetPage()
60 self.log.write("OnWizPageChanging: %s, %s\n" % (dir, page.__class__))
61
62
63 def OnWizCancel(self, evt):
64 pass
65
66
67 def OnRunSimpleWizard(self, evt):
68 # Create the wizard and the pages
69 wizard = wxWizard(self, self.ID_wiz, "Simple Wizard",
70 images.getWizTest1Bitmap())
71 page1 = TitledPage(wizard, "Page 1")
72 page2 = TitledPage(wizard, "Page 2")
73 page3 = TitledPage(wizard, "Page 3")
74 page4 = TitledPage(wizard, "Page 4")
75
76 page1.sizer.Add(wxStaticText(page1, -1, """\
77 This wizard is totally useless, but is meant to show how to
78 chain simple wizard pages together in a non-dynamic manner.
79 IOW, the order of the pages never changes, and so the
80 wxWizardPageSimple class can easily be used for the pages."""))
81 wizard.FitToPage(page1)
82
83 # Use the convenience Chain function to connect the pages
84 wxWizardPageSimple_Chain(page1, page2)
85 wxWizardPageSimple_Chain(page2, page3)
86 wxWizardPageSimple_Chain(page3, page4)
87
88 if wizard.RunWizard(page1):
89 wxMessageBox("Wizard completed successfully", "That's all folks!")
90 else:
91 wxMessageBox("Wizard was cancelled", "That's all folks!")
92
93
94
95 def OnRunDynamicWizard(self, evt):
96 pass
97
98 #----------------------------------------------------------------------
99
100 def runTest(frame, nb, log):
101 win = TestPanel(nb, log)
102 return win
103
104 #----------------------------------------------------------------------
105
106
107
108 overview = """<html><body>
109 <h2><center>wxWizard</center></h2>
110
111 wxWizard is the central class for implementing 'wizard-like'
112 dialogs. These dialogs are mostly familiar to Windows users and are
113 nothing else but a sequence of 'pages' each of them displayed inside a
114 dialog which has the buttons to pass to the next (and previous) pages.
115 <p>
116 The wizards are typically used to decompose a complex dialog into
117 several simple steps and are mainly useful to the novice users, hence
118 it is important to keep them as simple as possible.
119
120 </body></html>
121 """
122
123
124
125 if __name__ == '__main__':
126 import sys,os
127 import run
128 run.main(['', os.path.basename(sys.argv[0])])
129