]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxWizard.py
2 from wxPython
.wx
import *
3 from wxPython
.wizard
import *
7 #----------------------------------------------------------------------
9 class TitledPage(wxWizardPageSimple
):
10 def __init__(self
, parent
, title
):
11 wxWizardPageSimple
.__init
__(self
, parent
)
12 self
.sizer
= sizer
= wxBoxSizer(wxVERTICAL
)
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)
22 #----------------------------------------------------------------------
24 class TestPanel(wxPanel
):
27 def __init__(self
, parent
, log
):
29 wxPanel
.__init
__(self
, parent
, -1)
31 b
= wxButton(self
, -1, "Run Simple Wizard", pos
=(50,50))
32 EVT_BUTTON(self
, b
.GetId(), self
.OnRunSimpleWizard
)
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
)
39 def OnWizPageChanged(self
, evt
):
40 if evt
.GetDirection():
44 self
.log
.write("OnWizPageChanged: %s, %s\n" % (dir, evt
.GetPage()))
46 def OnWizPageChanging(self
, evt
):
47 if evt
.GetDirection():
51 self
.log
.write("OnWizPageChanging: %s, %s\n" % (dir, evt
.GetPage()))
53 def OnWizCancel(self
, evt
):
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")
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
)
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
)
78 if wizard
.RunWizard(page1
):
79 wxMessageBox("Wizard completed successfully", "That's all folks!")
81 wxMessageBox("Wizard was cancelled", "That's all folks!")
84 #----------------------------------------------------------------------
86 def runTest(frame
, nb
, log
):
87 win
= TestPanel(nb
, log
)
90 #----------------------------------------------------------------------
94 overview
= """<html><body>
95 <h2><center>wxWizard</center></h2>
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.
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.
111 if __name__
== '__main__':
114 run
.main(['', os
.path
.basename(sys
.argv
[0])])