2 from wxPython
.wx
import *
3 ##from wxPython.help import *
5 #---------------------------------------------------------------------------
6 # Create and set a help provider. Normally you would do this in
7 # the app's OnInit as it must be done before any SetHelpText calls.
8 provider
= wxSimpleHelpProvider()
9 wxHelpProvider_Set(provider
)
13 #---------------------------------------------------------------------------
15 class TestDialog(wxDialog
):
16 def __init__(self
, parent
, ID
, title
,
17 pos
=wxDefaultPosition
, size
=wxDefaultSize
,
18 style
=wxDEFAULT_DIALOG_STYLE
):
20 # Instead of calling wxDialog.__init__ we precreate the dialog
21 # object so we can set an extra style that must be set before
22 # creation, and then we create the GUI dialog using the Create
25 pre
.SetExtraStyle(wxDIALOG_EX_CONTEXTHELP
)
26 pre
.Create(parent
, ID
, title
, pos
, size
, style
)
28 # This next step is the most important, it turns this Python
29 # object into the real wrapper of the dialog (instead of pre)
30 # as far as the wxPython extension is concerned.
33 # Now continue with the normal construction of the dialog
35 sizer
= wxBoxSizer(wxVERTICAL
)
37 label
= wxStaticText(self
, -1, "This is a wxDialog")
38 label
.SetHelpText("This is the help text for the label")
39 sizer
.Add(label
, 0, wxALIGN_CENTRE|wxALL
, 5)
41 box
= wxBoxSizer(wxHORIZONTAL
)
43 label
= wxStaticText(self
, -1, "Field #1:")
44 label
.SetHelpText("This is the help text for the label")
45 box
.Add(label
, 0, wxALIGN_CENTRE|wxALL
, 5)
47 text
= wxTextCtrl(self
, -1, "", size
=(80,-1))
48 text
.SetHelpText("Here's some help text for field #1")
49 box
.Add(text
, 1, wxALIGN_CENTRE|wxALL
, 5)
51 sizer
.AddSizer(box
, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL
, 5)
53 box
= wxBoxSizer(wxHORIZONTAL
)
55 label
= wxStaticText(self
, -1, "Field #2:")
56 label
.SetHelpText("This is the help text for the label")
57 box
.Add(label
, 0, wxALIGN_CENTRE|wxALL
, 5)
59 text
= wxTextCtrl(self
, -1, "", size
=(80,-1))
60 text
.SetHelpText("Here's some help text for field #2")
61 box
.Add(text
, 1, wxALIGN_CENTRE|wxALL
, 5)
63 sizer
.AddSizer(box
, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL
, 5)
65 line
= wxStaticLine(self
, -1, size
=(20,-1), style
=wxLI_HORIZONTAL
)
66 sizer
.Add(line
, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP
, 5)
68 box
= wxBoxSizer(wxHORIZONTAL
)
70 if wxPlatform
!= "__WXMSW__":
71 btn
= wxContextHelpButton(self
)
72 box
.Add(btn
, 0, wxALIGN_CENTRE|wxALL
, 5)
74 btn
= wxButton(self
, wxID_OK
, " OK ")
76 btn
.SetHelpText("The OK button completes the dialog")
77 box
.Add(btn
, 0, wxALIGN_CENTRE|wxALL
, 5)
79 btn
= wxButton(self
, wxID_CANCEL
, " Cancel ")
80 btn
.SetHelpText("The Cancel button cnacels the dialog. (Duh!)")
81 box
.Add(btn
, 0, wxALIGN_CENTRE|wxALL
, 5)
83 sizer
.Add(box
, 0, wxALIGN_CENTER_VERTICAL|wxALL
, 5)
86 self
.SetAutoLayout(True)
91 #---------------------------------------------------------------------------
93 def runTest(frame
, nb
, log
):
94 win
= TestDialog(frame
, -1, "This is a wxDialog", size
=wxSize(350, 200),
95 #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
96 style
= wxDEFAULT_DIALOG_STYLE
101 log
.WriteText("You pressed OK\n")
103 log
.WriteText("You pressed Cancel\n")
107 #---------------------------------------------------------------------------
118 if __name__
== '__main__':
121 run
.main(['', os
.path
.basename(sys
.argv
[0])])