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