]>
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 #----------------------------------------------------------------------
25 #----------------------------------------------------------------------
27 class TestPanel(wxPanel
):
30 def __init__(self
, parent
, log
):
32 wxPanel
.__init
__(self
, parent
, -1)
34 b
= wxButton(self
, -1, "Run Simple Wizard", pos
=(50, 50))
35 EVT_BUTTON(self
, b
.GetId(), self
.OnRunSimpleWizard
)
37 b
= wxButton(self
, -1, "Run Dynamic Wizard", pos
=(50, 100))
38 EVT_BUTTON(self
, b
.GetId(), self
.OnRunDynamicWizard
)
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
)
45 def OnWizPageChanged(self
, evt
):
46 if evt
.GetDirection():
51 self
.log
.write("OnWizPageChanged: %s, %s\n" % (dir, page
.__class
__))
54 def OnWizPageChanging(self
, evt
):
55 if evt
.GetDirection():
60 self
.log
.write("OnWizPageChanging: %s, %s\n" % (dir, page
.__class
__))
63 def OnWizCancel(self
, evt
):
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")
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
)
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
)
88 if wizard
.RunWizard(page1
):
89 wxMessageBox("Wizard completed successfully", "That's all folks!")
91 wxMessageBox("Wizard was cancelled", "That's all folks!")
95 def OnRunDynamicWizard(self
, evt
):
98 #----------------------------------------------------------------------
100 def runTest(frame
, nb
, log
):
101 win
= TestPanel(nb
, log
)
104 #----------------------------------------------------------------------
108 overview
= """<html><body>
109 <h2><center>wxWizard</center></h2>
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.
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.
125 if __name__
== '__main__':
128 run
.main(['', os
.path
.basename(sys
.argv
[0])])