]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/wxDialog.py
removed second parameter from GetFirstChild calls
[wxWidgets.git] / wxPython / demo / wxDialog.py
1
2 from wxPython.wx import *
3 ##from wxPython.help import *
4
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)
10
11
12
13 #---------------------------------------------------------------------------
14
15 class TestDialog(wxDialog):
16 def __init__(self, parent, ID, title,
17 pos=wxDefaultPosition, size=wxDefaultSize,
18 style=wxDEFAULT_DIALOG_STYLE):
19
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
23 # method.
24 pre = wxPreDialog()
25 pre.SetExtraStyle(wxDIALOG_EX_CONTEXTHELP)
26 pre.Create(parent, ID, title, pos, size, style)
27
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.
31 self.PostCreate(pre)
32
33 # Now continue with the normal construction of the dialog
34 # contents
35 sizer = wxBoxSizer(wxVERTICAL)
36
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)
40
41 box = wxBoxSizer(wxHORIZONTAL)
42
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)
46
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)
50
51 sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)
52
53 box = wxBoxSizer(wxHORIZONTAL)
54
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)
58
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)
62
63 sizer.AddSizer(box, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5)
64
65 line = wxStaticLine(self, -1, size=(20,-1), style=wxLI_HORIZONTAL)
66 sizer.Add(line, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5)
67
68 box = wxBoxSizer(wxHORIZONTAL)
69
70 if wxPlatform != "__WXMSW__":
71 btn = wxContextHelpButton(self)
72 box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
73
74 btn = wxButton(self, wxID_OK, " OK ")
75 btn.SetDefault()
76 btn.SetHelpText("The OK button completes the dialog")
77 box.Add(btn, 0, wxALIGN_CENTRE|wxALL, 5)
78
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)
82
83 sizer.Add(box, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5)
84
85 self.SetSizer(sizer)
86 self.SetAutoLayout(True)
87 sizer.Fit(self)
88
89
90
91 #---------------------------------------------------------------------------
92
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
97 )
98 win.CenterOnScreen()
99 val = win.ShowModal()
100 if val == wxID_OK:
101 log.WriteText("You pressed OK\n")
102 else:
103 log.WriteText("You pressed Cancel\n")
104 win.Destroy()
105
106
107 #---------------------------------------------------------------------------
108
109
110
111
112
113 overview = """\
114 """
115
116
117
118 if __name__ == '__main__':
119 import sys,os
120 import run
121 run.main(['', os.path.basename(sys.argv[0])])
122