]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | #---------------------------------------------------------------------------- |
2 | # Name: _extra.py | |
1e4a197e | 3 | # Purpose: This file is appended to the shadow class file generated |
7bf85405 RD |
4 | # by SWIG. We add some unSWIGable things here. |
5 | # | |
6 | # Author: Robin Dunn | |
7 | # | |
8 | # Created: 6/30/97 | |
7bf85405 RD |
9 | # Copyright: (c) 1998 by Total Control Software |
10 | # Licence: wxWindows license | |
11 | #---------------------------------------------------------------------------- | |
12 | ||
13 | import sys | |
14 | ||
15 | #---------------------------------------------------------------------- | |
16 | # This gives this module's dictionary to the C++ extension code... | |
17 | ||
18 | _wxSetDictionary(vars()) | |
19 | ||
20 | ||
21 | #---------------------------------------------------------------------- | |
22 | #---------------------------------------------------------------------- | |
23 | # Helper function to link python methods to wxWindows virtual | |
24 | # functions by name. | |
25 | ||
26 | def _checkForCallback(obj, name, event, theID=-1): | |
27 | try: cb = getattr(obj, name) | |
28 | except: pass | |
29 | else: obj.Connect(theID, -1, event, cb) | |
30 | ||
7bf85405 RD |
31 | |
32 | #---------------------------------------------------------------------- | |
33 | #---------------------------------------------------------------------- | |
34 | # functions that look and act like the C++ Macros of the same name | |
35 | ||
36 | ||
37 | # Miscellaneous | |
38 | def EVT_SIZE(win, func): | |
39 | win.Connect(-1, -1, wxEVT_SIZE, func) | |
40 | ||
41 | def EVT_MOVE(win, func): | |
42 | win.Connect(-1, -1, wxEVT_MOVE, func) | |
43 | ||
44 | def EVT_CLOSE(win, func): | |
45 | win.Connect(-1, -1, wxEVT_CLOSE_WINDOW, func) | |
46 | ||
47 | def EVT_PAINT(win, func): | |
48 | win.Connect(-1, -1, wxEVT_PAINT, func) | |
49 | ||
50 | def EVT_ERASE_BACKGROUND(win, func): | |
51 | win.Connect(-1, -1, wxEVT_ERASE_BACKGROUND, func) | |
52 | ||
53 | def EVT_CHAR(win, func): | |
54 | win.Connect(-1, -1, wxEVT_CHAR, func) | |
55 | ||
56 | def EVT_CHAR_HOOK(win, func): | |
57 | win.Connect(-1, -1, wxEVT_CHAR_HOOK, func) | |
58 | ||
8bf5d46e RD |
59 | def EVT_KEY_DOWN(win, func): |
60 | win.Connect(-1, -1, wxEVT_KEY_DOWN, func) | |
61 | ||
62 | def EVT_KEY_UP(win, func): | |
63 | win.Connect(-1, -1, wxEVT_KEY_UP, func) | |
64 | ||
afb810d9 RD |
65 | def EVT_MENU_OPEN(win, func): |
66 | win.Connect(-1, -1, wxEVT_MENU_OPEN, func) | |
67 | ||
68 | def EVT_MENU_CLOSE(win, func): | |
69 | win.Connect(-1, -1, wxEVT_MENU_CLOSE, func) | |
70 | ||
7bf85405 RD |
71 | def EVT_MENU_HIGHLIGHT(win, id, func): |
72 | win.Connect(id, -1, wxEVT_MENU_HIGHLIGHT, func) | |
73 | ||
74 | def EVT_MENU_HIGHLIGHT_ALL(win, func): | |
75 | win.Connect(-1, -1, wxEVT_MENU_HIGHLIGHT, func) | |
76 | ||
77 | def EVT_SET_FOCUS(win, func): | |
78 | win.Connect(-1, -1, wxEVT_SET_FOCUS, func) | |
79 | ||
80 | def EVT_KILL_FOCUS(win, func): | |
81 | win.Connect(-1, -1, wxEVT_KILL_FOCUS, func) | |
82 | ||
7b7ac0ab RD |
83 | def EVT_CHILD_FOCUS(win, func): |
84 | win.Connect(-1, -1, wxEVT_CHILD_FOCUS, func) | |
85 | ||
7bf85405 RD |
86 | def EVT_ACTIVATE(win, func): |
87 | win.Connect(-1, -1, wxEVT_ACTIVATE, func) | |
88 | ||
89 | def EVT_ACTIVATE_APP(win, func): | |
90 | win.Connect(-1, -1, wxEVT_ACTIVATE_APP, func) | |
91 | ||
92 | def EVT_END_SESSION(win, func): | |
93 | win.Connect(-1, -1, wxEVT_END_SESSION, func) | |
94 | ||
95 | def EVT_QUERY_END_SESSION(win, func): | |
96 | win.Connect(-1, -1, wxEVT_QUERY_END_SESSION, func) | |
97 | ||
98 | def EVT_DROP_FILES(win, func): | |
99 | win.Connect(-1, -1, wxEVT_DROP_FILES, func) | |
100 | ||
101 | def EVT_INIT_DIALOG(win, func): | |
102 | win.Connect(-1, -1, wxEVT_INIT_DIALOG, func) | |
103 | ||
104 | def EVT_SYS_COLOUR_CHANGED(win, func): | |
105 | win.Connect(-1, -1, wxEVT_SYS_COLOUR_CHANGED, func) | |
106 | ||
be43cc44 RD |
107 | def EVT_DISPLAY_CHANGED(win, func): |
108 | win.Connect(-1, -1, wxEVT_DISPLAY_CHANGED, func) | |
109 | ||
7bf85405 RD |
110 | def EVT_SHOW(win, func): |
111 | win.Connect(-1, -1, wxEVT_SHOW, func) | |
112 | ||
113 | def EVT_MAXIMIZE(win, func): | |
114 | win.Connect(-1, -1, wxEVT_MAXIMIZE, func) | |
115 | ||
116 | def EVT_ICONIZE(win, func): | |
117 | win.Connect(-1, -1, wxEVT_ICONIZE, func) | |
118 | ||
119 | def EVT_NAVIGATION_KEY(win, func): | |
120 | win.Connect(-1, -1, wxEVT_NAVIGATION_KEY, func) | |
121 | ||
3af4e610 RD |
122 | def EVT_PALETTE_CHANGED(win, func): |
123 | win.Connect(-1, -1, wxEVT_PALETTE_CHANGED, func) | |
124 | ||
125 | def EVT_QUERY_NEW_PALETTE(win, func): | |
126 | win.Connect(-1, -1, wxEVT_QUERY_NEW_PALETTE, func) | |
127 | ||
128 | def EVT_WINDOW_CREATE(win, func): | |
54b96882 | 129 | win.Connect(-1, -1, wxEVT_CREATE, func) |
3af4e610 RD |
130 | |
131 | def EVT_WINDOW_DESTROY(win, func): | |
54b96882 | 132 | win.Connect(-1, -1, wxEVT_DESTROY, func) |
3af4e610 | 133 | |
1e4a197e RD |
134 | def EVT_WINDOW_CREATE_ID(win, id, func): |
135 | win.Connect(id, -1, wxEVT_CREATE, func) | |
136 | ||
137 | def EVT_WINDOW_DESTROY_ID(win, id, func): | |
138 | win.Connect(id, -1, wxEVT_DESTROY, func) | |
139 | ||
203c2f9a RD |
140 | def EVT_SET_CURSOR(win, func): |
141 | win.Connect(-1, -1, wxEVT_SET_CURSOR, func) | |
142 | ||
3af4e610 RD |
143 | |
144 | ||
cf694132 RD |
145 | def EVT_IDLE(win, func): |
146 | win.Connect(-1, -1, wxEVT_IDLE, func) | |
147 | ||
bb0054cd RD |
148 | def EVT_UPDATE_UI(win, id, func): |
149 | win.Connect(id, -1, wxEVT_UPDATE_UI, func) | |
150 | ||
eb715945 RD |
151 | def EVT_UPDATE_UI_RANGE(win, id, id2, func): |
152 | win.Connect(id, id2, wxEVT_UPDATE_UI, func) | |
153 | ||
7bf85405 RD |
154 | |
155 | # Mouse Events | |
156 | def EVT_LEFT_DOWN(win, func): | |
157 | win.Connect(-1, -1, wxEVT_LEFT_DOWN, func) | |
158 | ||
159 | def EVT_LEFT_UP(win, func): | |
160 | win.Connect(-1, -1, wxEVT_LEFT_UP, func) | |
161 | ||
162 | def EVT_MIDDLE_DOWN(win, func): | |
163 | win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func) | |
164 | ||
165 | def EVT_MIDDLE_UP(win, func): | |
166 | win.Connect(-1, -1, wxEVT_MIDDLE_UP, func) | |
167 | ||
168 | def EVT_RIGHT_DOWN(win, func): | |
169 | win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func) | |
170 | ||
171 | def EVT_RIGHT_UP(win, func): | |
172 | win.Connect(-1, -1, wxEVT_RIGHT_UP, func) | |
173 | ||
174 | def EVT_MOTION(win, func): | |
175 | win.Connect(-1, -1, wxEVT_MOTION, func) | |
176 | ||
177 | def EVT_LEFT_DCLICK(win, func): | |
178 | win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func) | |
179 | ||
180 | def EVT_MIDDLE_DCLICK(win, func): | |
181 | win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func) | |
182 | ||
183 | def EVT_RIGHT_DCLICK(win, func): | |
184 | win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func) | |
185 | ||
186 | def EVT_LEAVE_WINDOW(win, func): | |
187 | win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func) | |
188 | ||
189 | def EVT_ENTER_WINDOW(win, func): | |
190 | win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func) | |
191 | ||
d1679124 RD |
192 | def EVT_MOUSEWHEEL(win, func): |
193 | win.Connect(-1, -1, wxEVT_MOUSEWHEEL, func) | |
7bf85405 RD |
194 | |
195 | # all mouse events | |
196 | def EVT_MOUSE_EVENTS(win, func): | |
197 | win.Connect(-1, -1, wxEVT_LEFT_DOWN, func) | |
198 | win.Connect(-1, -1, wxEVT_LEFT_UP, func) | |
199 | win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func) | |
200 | win.Connect(-1, -1, wxEVT_MIDDLE_UP, func) | |
201 | win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func) | |
202 | win.Connect(-1, -1, wxEVT_RIGHT_UP, func) | |
203 | win.Connect(-1, -1, wxEVT_MOTION, func) | |
204 | win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func) | |
205 | win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func) | |
206 | win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func) | |
207 | win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func) | |
208 | win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func) | |
209 | ||
6d26dc89 RD |
210 | def EVT_MOUSE_CAPTURE_CHANGED(win, func): |
211 | win.Connect(-1, -1, wxEVT_MOUSE_CAPTURE_CHANGED, func) | |
212 | ||
7bf85405 RD |
213 | # EVT_COMMAND |
214 | def EVT_COMMAND(win, id, cmd, func): | |
215 | win.Connect(id, -1, cmd, func) | |
216 | ||
217 | def EVT_COMMAND_RANGE(win, id1, id2, cmd, func): | |
218 | win.Connect(id1, id2, cmd, func) | |
219 | ||
26b9cf27 | 220 | |
7bf85405 RD |
221 | # Scrolling |
222 | def EVT_SCROLL(win, func): | |
83f3dd45 RD |
223 | win.Connect(-1, -1, wxEVT_SCROLL_TOP, func) |
224 | win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func) | |
225 | win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func) | |
226 | win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func) | |
227 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func) | |
228 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
229 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func) | |
26b9cf27 | 230 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE,func) |
83f3dd45 | 231 | win.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL, func) |
7bf85405 RD |
232 | |
233 | def EVT_SCROLL_TOP(win, func): | |
234 | win.Connect(-1, -1, wxEVT_SCROLL_TOP, func) | |
235 | ||
236 | def EVT_SCROLL_BOTTOM(win, func): | |
237 | win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func) | |
238 | ||
239 | def EVT_SCROLL_LINEUP(win, func): | |
240 | win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func) | |
241 | ||
242 | def EVT_SCROLL_LINEDOWN(win, func): | |
243 | win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func) | |
244 | ||
245 | def EVT_SCROLL_PAGEUP(win, func): | |
246 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func) | |
247 | ||
248 | def EVT_SCROLL_PAGEDOWN(win, func): | |
249 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
250 | ||
251 | def EVT_SCROLL_THUMBTRACK(win, func): | |
252 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func) | |
253 | ||
26b9cf27 RD |
254 | def EVT_SCROLL_THUMBRELEASE(win, func): |
255 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE, func) | |
256 | ||
83f3dd45 RD |
257 | def EVT_SCROLL_ENDSCROLL(win, func): |
258 | win.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL, func) | |
259 | ||
7bf85405 RD |
260 | |
261 | ||
262 | # Scrolling, with an id | |
263 | def EVT_COMMAND_SCROLL(win, id, func): | |
264 | win.Connect(id, -1, wxEVT_SCROLL_TOP, func) | |
265 | win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func) | |
266 | win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func) | |
267 | win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func) | |
268 | win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func) | |
269 | win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
270 | win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func) | |
26b9cf27 | 271 | win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE,func) |
1e4a197e | 272 | win.Connect(id, -1, wxEVT_SCROLL_ENDSCROLL, func) |
7bf85405 RD |
273 | |
274 | def EVT_COMMAND_SCROLL_TOP(win, id, func): | |
275 | win.Connect(id, -1, wxEVT_SCROLL_TOP, func) | |
276 | ||
277 | def EVT_COMMAND_SCROLL_BOTTOM(win, id, func): | |
278 | win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func) | |
279 | ||
280 | def EVT_COMMAND_SCROLL_LINEUP(win, id, func): | |
281 | win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func) | |
282 | ||
283 | def EVT_COMMAND_SCROLL_LINEDOWN(win, id, func): | |
284 | win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func) | |
285 | ||
286 | def EVT_COMMAND_SCROLL_PAGEUP(win, id, func): | |
287 | win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func) | |
288 | ||
289 | def EVT_COMMAND_SCROLL_PAGEDOWN(win, id, func): | |
290 | win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
291 | ||
292 | def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func): | |
293 | win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func) | |
294 | ||
26b9cf27 RD |
295 | def EVT_COMMAND_SCROLL_THUMBRELEASE(win, id, func): |
296 | win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE, func) | |
297 | ||
83f3dd45 RD |
298 | def EVT_COMMAND_SCROLL_ENDSCROLL(win, id, func): |
299 | win.Connect(id, -1, wxEVT_SCROLL_ENDSCROLL, func) | |
300 | ||
d426c97e RD |
301 | #--- |
302 | def EVT_SCROLLWIN(win, func): | |
26b9cf27 RD |
303 | win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) |
304 | win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
305 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
306 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
307 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
308 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
309 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
310 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func) | |
d426c97e RD |
311 | |
312 | def EVT_SCROLLWIN_TOP(win, func): | |
313 | win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) | |
314 | ||
315 | def EVT_SCROLLWIN_BOTTOM(win, func): | |
316 | win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
317 | ||
318 | def EVT_SCROLLWIN_LINEUP(win, func): | |
319 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
320 | ||
321 | def EVT_SCROLLWIN_LINEDOWN(win, func): | |
322 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
323 | ||
324 | def EVT_SCROLLWIN_PAGEUP(win, func): | |
325 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
326 | ||
327 | def EVT_SCROLLWIN_PAGEDOWN(win, func): | |
328 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
329 | ||
330 | def EVT_SCROLLWIN_THUMBTRACK(win, func): | |
331 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
332 | ||
26b9cf27 RD |
333 | def EVT_SCROLLWIN_THUMBRELEASE(win, func): |
334 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func) | |
335 | ||
d426c97e RD |
336 | |
337 | ||
338 | # Scrolling, with an id | |
339 | def EVT_COMMAND_SCROLLWIN(win, id, func): | |
26b9cf27 RD |
340 | win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) |
341 | win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
342 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
343 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
344 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
345 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
346 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
347 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func) | |
d426c97e RD |
348 | |
349 | def EVT_COMMAND_SCROLLWIN_TOP(win, id, func): | |
350 | win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) | |
351 | ||
352 | def EVT_COMMAND_SCROLLWIN_BOTTOM(win, id, func): | |
353 | win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
354 | ||
355 | def EVT_COMMAND_SCROLLWIN_LINEUP(win, id, func): | |
356 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
357 | ||
358 | def EVT_COMMAND_SCROLLWIN_LINEDOWN(win, id, func): | |
359 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
360 | ||
361 | def EVT_COMMAND_SCROLLWIN_PAGEUP(win, id, func): | |
362 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
363 | ||
364 | def EVT_COMMAND_SCROLLWIN_PAGEDOWN(win, id, func): | |
365 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
366 | ||
367 | def EVT_COMMAND_SCROLLWIN_THUMBTRACK(win, id, func): | |
368 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
7bf85405 | 369 | |
26b9cf27 RD |
370 | def EVT_COMMAND_SCROLLWIN_THUMBRELEASE(win, id, func): |
371 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func) | |
372 | ||
373 | ||
7bf85405 RD |
374 | # Convenience commands |
375 | def EVT_BUTTON(win, id, func): | |
376 | win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func) | |
377 | ||
378 | def EVT_CHECKBOX(win, id, func): | |
379 | win.Connect(id, -1, wxEVT_COMMAND_CHECKBOX_CLICKED, func) | |
380 | ||
381 | def EVT_CHOICE(win, id, func): | |
382 | win.Connect(id, -1, wxEVT_COMMAND_CHOICE_SELECTED, func) | |
383 | ||
384 | def EVT_LISTBOX(win, id, func): | |
385 | win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_SELECTED, func) | |
386 | ||
387 | def EVT_LISTBOX_DCLICK(win, id, func): | |
388 | win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, func) | |
389 | ||
390 | def EVT_TEXT(win, id, func): | |
391 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_UPDATED, func) | |
392 | ||
393 | def EVT_TEXT_ENTER(win, id, func): | |
394 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_ENTER, func) | |
395 | ||
c7e7022c RD |
396 | def EVT_TEXT_URL(win, id, func): |
397 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_URL, func) | |
398 | ||
00b6c4e3 RD |
399 | def EVT_TEXT_MAXLEN(win, id, func): |
400 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_MAXLEN, func) | |
401 | ||
7bf85405 RD |
402 | def EVT_MENU(win, id, func): |
403 | win.Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED, func) | |
404 | ||
405 | def EVT_MENU_RANGE(win, id1, id2, func): | |
406 | win.Connect(id1, id2, wxEVT_COMMAND_MENU_SELECTED, func) | |
407 | ||
408 | def EVT_SLIDER(win, id, func): | |
409 | win.Connect(id, -1, wxEVT_COMMAND_SLIDER_UPDATED, func) | |
410 | ||
411 | def EVT_RADIOBOX(win, id, func): | |
412 | win.Connect(id, -1, wxEVT_COMMAND_RADIOBOX_SELECTED, func) | |
413 | ||
414 | def EVT_RADIOBUTTON(win, id, func): | |
415 | win.Connect(id, -1, wxEVT_COMMAND_RADIOBUTTON_SELECTED, func) | |
416 | ||
417 | def EVT_VLBOX(win, id, func): | |
418 | win.Connect(id, -1, wxEVT_COMMAND_VLBOX_SELECTED, func) | |
419 | ||
420 | def EVT_COMBOBOX(win, id, func): | |
421 | win.Connect(id, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, func) | |
422 | ||
423 | def EVT_TOOL(win, id, func): | |
424 | win.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED, func) | |
425 | ||
3af4e610 RD |
426 | def EVT_TOOL_RANGE(win, id, id2, func): |
427 | win.Connect(id, id2, wxEVT_COMMAND_TOOL_CLICKED, func) | |
428 | ||
7bf85405 RD |
429 | def EVT_TOOL_RCLICKED(win, id, func): |
430 | win.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED, func) | |
431 | ||
3af4e610 RD |
432 | def EVT_TOOL_RCLICKED_RANGE(win, id, id2, func): |
433 | win.Connect(id, id2, wxEVT_COMMAND_TOOL_RCLICKED, func) | |
434 | ||
7bf85405 RD |
435 | def EVT_TOOL_ENTER(win, id, func): |
436 | win.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER, func) | |
437 | ||
438 | def EVT_CHECKLISTBOX(win, id, func): | |
439 | win.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, func) | |
440 | ||
3af4e610 RD |
441 | def EVT_SPINCTRL(win, id, func): |
442 | win.Connect(id, -1, wxEVT_COMMAND_SPINCTRL_UPDATED, func) | |
443 | ||
444 | ||
7bf85405 RD |
445 | |
446 | # Generic command events | |
447 | ||
448 | def EVT_COMMAND_LEFT_CLICK(win, id, func): | |
449 | win.Connect(id, -1, wxEVT_COMMAND_LEFT_CLICK, func) | |
450 | ||
451 | def EVT_COMMAND_LEFT_DCLICK(win, id, func): | |
452 | win.Connect(id, -1, wxEVT_COMMAND_LEFT_DCLICK, func) | |
453 | ||
454 | def EVT_COMMAND_RIGHT_CLICK(win, id, func): | |
455 | win.Connect(id, -1, wxEVT_COMMAND_RIGHT_CLICK, func) | |
456 | ||
457 | def EVT_COMMAND_RIGHT_DCLICK(win, id, func): | |
458 | win.Connect(id, -1, wxEVT_COMMAND_RIGHT_DCLICK, func) | |
459 | ||
460 | def EVT_COMMAND_SET_FOCUS(win, id, func): | |
461 | win.Connect(id, -1, wxEVT_COMMAND_SET_FOCUS, func) | |
462 | ||
463 | def EVT_COMMAND_KILL_FOCUS(win, id, func): | |
464 | win.Connect(id, -1, wxEVT_COMMAND_KILL_FOCUS, func) | |
465 | ||
466 | def EVT_COMMAND_ENTER(win, id, func): | |
467 | win.Connect(id, -1, wxEVT_COMMAND_ENTER, func) | |
468 | ||
469 | ||
d5c9047a | 470 | # wxNotebook events |
7bf85405 RD |
471 | def EVT_NOTEBOOK_PAGE_CHANGED(win, id, func): |
472 | win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, func) | |
473 | ||
474 | def EVT_NOTEBOOK_PAGE_CHANGING(win, id, func): | |
475 | win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, func) | |
476 | ||
477 | ||
b639c3c5 | 478 | # wxSpinButton |
62bd0874 RD |
479 | def EVT_SPIN_UP(win, id, func): |
480 | win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func) | |
481 | ||
482 | def EVT_SPIN_DOWN(win, id, func): | |
f6bcfd97 | 483 | win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func) |
62bd0874 RD |
484 | |
485 | def EVT_SPIN(win, id, func): | |
62bd0874 RD |
486 | win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func) |
487 | ||
488 | ||
b639c3c5 RD |
489 | # wxTaskBarIcon |
490 | def EVT_TASKBAR_MOVE(win, func): | |
491 | win.Connect(-1, -1, wxEVT_TASKBAR_MOVE, func) | |
492 | ||
493 | def EVT_TASKBAR_LEFT_DOWN(win, func): | |
494 | win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DOWN, func) | |
495 | ||
496 | def EVT_TASKBAR_LEFT_UP(win, func): | |
497 | win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_UP, func) | |
498 | ||
499 | def EVT_TASKBAR_RIGHT_DOWN(win, func): | |
500 | win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DOWN, func) | |
501 | ||
502 | def EVT_TASKBAR_RIGHT_UP(win, func): | |
503 | win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_UP, func) | |
504 | ||
505 | def EVT_TASKBAR_LEFT_DCLICK(win, func): | |
506 | win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DCLICK, func) | |
507 | ||
508 | def EVT_TASKBAR_RIGHT_DCLICK(win, func): | |
509 | win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DCLICK, func) | |
510 | ||
511 | ||
08127323 RD |
512 | # wxSashWindow |
513 | def EVT_SASH_DRAGGED(win, id, func): | |
514 | win.Connect(id, -1, wxEVT_SASH_DRAGGED, func) | |
515 | ||
516 | def EVT_SASH_DRAGGED_RANGE(win, id1, id2, func): | |
517 | win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func) | |
518 | ||
519 | def EVT_QUERY_LAYOUT_INFO(win, func): | |
520 | win.Connect(-1, -1, wxEVT_EVT_QUERY_LAYOUT_INFO, func) | |
521 | ||
522 | def EVT_CALCULATE_LAYOUT(win, func): | |
523 | win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func) | |
524 | ||
525 | ||
bb0054cd RD |
526 | #wxSplitterWindow |
527 | def EVT_SPLITTER_SASH_POS_CHANGING(win, id, func): | |
528 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, func) | |
529 | ||
530 | def EVT_SPLITTER_SASH_POS_CHANGED(win, id, func): | |
531 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, func) | |
532 | ||
533 | def EVT_SPLITTER_UNSPLIT(win, id, func): | |
534 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_UNSPLIT, func) | |
535 | ||
536 | def EVT_SPLITTER_DOUBLECLICKED(win, id, func): | |
537 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, func) | |
538 | ||
b639c3c5 | 539 | |
f6bcfd97 BP |
540 | # wxTimer |
541 | def EVT_TIMER(win, id, func): | |
542 | win.Connect(id, -1, wxEVT_TIMER, func) | |
543 | ||
c368d904 RD |
544 | # wxProcess |
545 | def EVT_END_PROCESS(eh, id, func): | |
546 | eh.Connect(id, -1, wxEVT_END_PROCESS, func) | |
f6bcfd97 | 547 | |
185d7c3e RD |
548 | |
549 | # wxJoyStick | |
550 | def EVT_JOY_DOWN(win, func): | |
ac346f50 | 551 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_DOWN, func) |
185d7c3e RD |
552 | |
553 | def EVT_JOY_UP(win, func): | |
ac346f50 | 554 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_UP, func) |
185d7c3e RD |
555 | |
556 | def EVT_JOY_MOVE(win, func): | |
557 | win.Connect(-1, -1, wxEVT_JOY_MOVE, func) | |
558 | ||
559 | def EVT_JOY_ZMOVE(win, func): | |
560 | win.Connect(-1, -1, wxEVT_JOY_ZMOVE, func) | |
561 | ||
562 | def EVT_JOYSTICK_EVENTS(win, func): | |
ac346f50 RD |
563 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_DOWN, func) |
564 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_UP, func) | |
185d7c3e RD |
565 | win.Connect(-1, -1, wxEVT_JOY_MOVE, func) |
566 | win.Connect(-1, -1, wxEVT_JOY_ZMOVE, func) | |
567 | ||
d1679124 RD |
568 | |
569 | def EVT_TOGGLEBUTTON(win, id, func): | |
570 | win.Connect(id, -1, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, func) | |
571 | ||
572 | ||
4f3449b4 | 573 | |
4f3449b4 RD |
574 | def EVT_CONTEXT_MENU(win, func): |
575 | win.Connect(-1, -1, wxEVT_CONTEXT_MENU, func) | |
576 | ||
577 | ||
9c039d08 | 578 | #---------------------------------------------------------------------- |
7bf85405 RD |
579 | |
580 | class wxTimer(wxPyTimer): | |
185d7c3e RD |
581 | def __init__(self, evtHandler = None, id = -1): |
582 | if evtHandler is None: | |
583 | wxPyTimer.__init__(self, self.Notify) # derived class must provide | |
584 | # Notify(self) method. | |
585 | else: | |
586 | wxPyTimer.__init__(self, None) | |
587 | self.SetOwner(evtHandler, id) | |
7bf85405 | 588 | |
7bf85405 RD |
589 | #---------------------------------------------------------------------- |
590 | # aliases | |
591 | ||
b639c3c5 | 592 | wxColor = wxColour |
7bf85405 | 593 | wxNamedColor = wxNamedColour |
ecc08ead | 594 | wxPen = wxPyPen |
293a0a86 | 595 | wxScrollbar = wxScrollBar |
1e4a197e RD |
596 | wxPoint2D = wxPoint2DDouble |
597 | ||
598 | wxPyAssertionError = wxc.wxPyAssertionError | |
293a0a86 | 599 | |
af309447 | 600 | |
6999b0d8 | 601 | # backwards compatibility |
1e4a197e RD |
602 | wxNoRefBitmap = wxBitmap |
603 | wxPyDefaultPosition = wxDefaultPosition | |
604 | wxPyDefaultSize = wxDefaultSize | |
605 | NULL = None | |
68320e40 RD |
606 | wxSystemSettings_GetSystemColour = wxSystemSettings_GetColour |
607 | wxSystemSettings_GetSystemFont = wxSystemSettings_GetFont | |
608 | wxSystemSettings_GetSystemMetric = wxSystemSettings_GetMetric | |
00b6c4e3 | 609 | |
1e4a197e RD |
610 | |
611 | # workarounds for bad wxRTTI names | |
612 | __wxPyPtrTypeMap['wxGauge95'] = 'wxGauge' | |
613 | ||
614 | ||
615 | ||
616 | def NewId(): | |
617 | import warnings | |
618 | warnings.warn("Use wxNewId instead", DeprecationWarning, 2) | |
619 | return wxNewId() | |
620 | ||
621 | def RegisterId(ID): | |
622 | import warnings | |
623 | warnings.warn("Use wxRegisterId instead", DeprecationWarning, 2) | |
624 | return wxRegisterId(ID) | |
625 | ||
626 | ||
627 | ||
628 | # Use Python's bool constants if available, make aliases if not | |
629 | try: | |
630 | True | |
631 | except NameError: | |
632 | True = 1==1 | |
633 | False = 1==0 | |
634 | ||
635 | # Backwards compaatible | |
636 | TRUE = true = True | |
637 | FALSE = false = False | |
638 | ||
639 | ||
a3fbed81 | 640 | #---------------------------------------------------------------------- |
00b6c4e3 RD |
641 | # wxGTK sets the locale when initialized. Doing this at the Python |
642 | # level should set it up to match what GTK is doing at the C level. | |
293a0a86 RD |
643 | if wxPlatform == "__WXGTK__": |
644 | try: | |
645 | import locale | |
646 | locale.setlocale(locale.LC_ALL, "") | |
647 | except: | |
648 | pass | |
00b6c4e3 | 649 | |
1e4a197e RD |
650 | if wxPlatform == "__WXMSW__": |
651 | import os | |
652 | localedir = os.path.join(os.path.split(__file__)[0], "locale") | |
653 | wxLocale_AddCatalogLookupPathPrefix(localedir) | |
654 | del os | |
a3fbed81 RD |
655 | |
656 | #---------------------------------------------------------------------- | |
657 | # wxWindows version numbers. wxPython version is in __version__. | |
658 | ||
659 | wxMAJOR_VERSION = wxc.wxMAJOR_VERSION | |
660 | wxMINOR_VERSION = wxc.wxMINOR_VERSION | |
661 | wxRELEASE_NUMBER = wxc.wxRELEASE_NUMBER | |
662 | wxVERSION_STRING = wxc.wxVERSION_STRING | |
663 | wxVERSION_NUMBER = wxc.wxVERSION_NUMBER | |
664 | ||
665 | wxVERSION = (wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) | |
666 | ||
667 | ||
8bf5d46e RD |
668 | #---------------------------------------------------------------------- |
669 | # This helper function will take a wxPython object and convert it to | |
670 | # another wxPython object type. This will not be able to create objects | |
7bcd390c | 671 | # that are derived from wxPython classes by the user, only those that are |
8bf5d46e RD |
672 | # actually part of wxPython and directly corespond to C++ objects. |
673 | # | |
674 | # This is useful in situations where some method returns a generic | |
675 | # type such as wxWindow, but you know that it is actually some | |
676 | # derived type such as a wxTextCtrl. You can't call wxTextCtrl specific | |
677 | # methods on a wxWindow object, but you can use this function to | |
678 | # create a wxTextCtrl object that will pass the same pointer to | |
679 | # the C++ code. You use it like this: | |
680 | # | |
681 | # textCtrl = wxPyTypeCast(window, "wxTextCtrl") | |
682 | # | |
683 | # | |
684 | # WARNING: Using this function to type cast objects into types that | |
685 | # they are not is not recommended and is likely to cause your | |
686 | # program to crash... Hard. | |
687 | # | |
688 | ||
689 | def wxPyTypeCast(obj, typeStr): | |
83b18bab RD |
690 | if obj is None: |
691 | return None | |
9416aa89 RD |
692 | theClass = globals()[typeStr+"Ptr"] |
693 | typeStr = __wxPyPtrTypeMap.get(typeStr, typeStr) | |
8bf5d46e | 694 | if hasattr(obj, "this"): |
2aab8f16 RD |
695 | # if already the right type then just return it |
696 | if isinstance(obj, theClass) or obj.__class__ is theClass: | |
9416aa89 | 697 | return obj |
8bf5d46e RD |
698 | newPtr = ptrcast(obj.this, typeStr+"_p") |
699 | else: | |
700 | newPtr = ptrcast(obj, typeStr+"_p") | |
8bf5d46e | 701 | theObj = theClass(newPtr) |
6999b0d8 RD |
702 | if hasattr(obj, "this"): |
703 | theObj.thisown = obj.thisown | |
8bf5d46e RD |
704 | return theObj |
705 | ||
1e4a197e RD |
706 | #---------------------------------------------------------------------------- |
707 | # An isinstance for Pythons < 2.2 that can check a sequence of class objects | |
708 | # like the one in 2.2 can. | |
709 | ||
710 | def wxPy_isinstance(obj, klasses): | |
711 | import types | |
712 | if sys.version[:3] < "2.2" and type(klasses) in [types.TupleType, types.ListType]: | |
713 | for klass in klasses: | |
714 | if isinstance(obj, klass): return True | |
715 | return False | |
716 | else: | |
717 | return isinstance(obj, klasses) | |
8bf5d46e | 718 | |
4acff284 | 719 | #---------------------------------------------------------------------------- |
72797a7d RD |
720 | _wxCallAfterId = None |
721 | ||
722 | def wxCallAfter(callable, *args, **kw): | |
723 | """ | |
724 | Call the specified function after the current and pending event | |
c2dac736 RD |
725 | handlers have been completed. This is also good for making GUI |
726 | method calls from non-GUI threads. | |
72797a7d RD |
727 | """ |
728 | app = wxGetApp() | |
729 | assert app, 'No wxApp created yet' | |
730 | ||
731 | global _wxCallAfterId | |
732 | if _wxCallAfterId is None: | |
1542ea39 | 733 | _wxCallAfterId = wxNewEventType() |
72797a7d RD |
734 | app.Connect(-1, -1, _wxCallAfterId, |
735 | lambda event: apply(event.callable, event.args, event.kw) ) | |
736 | evt = wxPyEvent() | |
737 | evt.SetEventType(_wxCallAfterId) | |
738 | evt.callable = callable | |
739 | evt.args = args | |
740 | evt.kw = kw | |
741 | wxPostEvent(app, evt) | |
742 | ||
1e4a197e RD |
743 | # an alias |
744 | wxRunLater = wxCallAfter | |
745 | ||
72797a7d | 746 | #---------------------------------------------------------------------- |
4acff284 | 747 | |
7cdaed0b RD |
748 | class wxPyDeadObjectError(AttributeError): |
749 | pass | |
4acff284 RD |
750 | |
751 | class _wxPyDeadObject: | |
752 | """ | |
753 | Instances of wx objects that are OOR capable will have their __class__ | |
754 | changed to this class when the C++ object is deleted. This should help | |
755 | prevent crashes due to referencing a bogus C++ pointer. | |
756 | """ | |
7cdaed0b | 757 | reprStr = "wxPython wrapper for DELETED %s object! (The C++ object no longer exists.)" |
fc51b8c3 | 758 | attrStr = "The C++ part of the %s object has been deleted, attribute access no longer allowed." |
7cdaed0b | 759 | |
4acff284 RD |
760 | def __repr__( self ): |
761 | if not hasattr(self, "_name"): | |
762 | self._name = "[unknown]" | |
7cdaed0b | 763 | return self.reprStr % self._name |
4acff284 RD |
764 | |
765 | def __getattr__( self, *args ): | |
766 | if not hasattr(self, "_name"): | |
767 | self._name = "[unknown]" | |
7cdaed0b RD |
768 | raise wxPyDeadObjectError( self.attrStr % self._name ) |
769 | ||
770 | def __nonzero__(self): | |
771 | return 0 | |
4acff284 RD |
772 | |
773 | ||
c856d372 | 774 | #---------------------------------------------------------------------- |
7bf85405 RD |
775 | #---------------------------------------------------------------------- |
776 | ||
2f90df85 RD |
777 | class wxPyOnDemandOutputWindow: |
778 | def __init__(self, title = "wxPython: stdout/stderr"): | |
779 | self.frame = None | |
780 | self.title = title | |
c856d372 | 781 | self.parent = None |
2f90df85 RD |
782 | |
783 | def SetParent(self, parent): | |
784 | self.parent = parent | |
cf694132 | 785 | |
2f90df85 RD |
786 | def OnCloseWindow(self, event): |
787 | if self.frame != None: | |
788 | self.frame.Destroy() | |
789 | self.frame = None | |
790 | self.text = None | |
7bf85405 | 791 | |
6e18ca6c | 792 | # These methods provide the file-like output behaviour. |
2f90df85 | 793 | def write(self, str): |
6e18ca6c RD |
794 | if not wxThread_IsMain(): |
795 | # Aquire the GUI mutex before making GUI calls. Mutex is released | |
03a2c062 | 796 | # when locker is deleted at the end of this function. |
6e18ca6c RD |
797 | locker = wxMutexGuiLocker() |
798 | ||
2f90df85 | 799 | if not self.frame: |
03a2c062 RD |
800 | self.frame = wxFrame(self.parent, -1, self.title, |
801 | style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE) | |
2f90df85 RD |
802 | self.text = wxTextCtrl(self.frame, -1, "", |
803 | style = wxTE_MULTILINE|wxTE_READONLY) | |
804 | self.frame.SetSize(wxSize(450, 300)) | |
1e4a197e | 805 | self.frame.Show(True) |
2f90df85 RD |
806 | EVT_CLOSE(self.frame, self.OnCloseWindow) |
807 | self.text.AppendText(str) | |
808 | ||
809 | def close(self): | |
a1df7a95 | 810 | if self.frame != None: |
6e18ca6c RD |
811 | if not wxThread_IsMain(): |
812 | locker = wxMutexGuiLocker() | |
c856d372 | 813 | self.frame.Close() |
7bf85405 | 814 | |
7bf85405 | 815 | |
606d919c | 816 | _defRedirect = (wxPlatform == '__WXMSW__' or wxPlatform == '__WXMAC__') |
7bf85405 RD |
817 | |
818 | #---------------------------------------------------------------------- | |
819 | # The main application class. Derive from this and implement an OnInit | |
820 | # method that creates a frame and then calls self.SetTopWindow(frame) | |
821 | ||
822 | class wxApp(wxPyApp): | |
823 | error = 'wxApp.error' | |
2f90df85 | 824 | outputWindowClass = wxPyOnDemandOutputWindow |
7bf85405 | 825 | |
1e4a197e | 826 | def __init__(self, redirect=_defRedirect, filename=None, useBestVisual=False): |
7bf85405 RD |
827 | wxPyApp.__init__(self) |
828 | self.stdioWin = None | |
829 | self.saveStdio = (sys.stdout, sys.stderr) | |
1e4a197e RD |
830 | |
831 | # This has to be done before OnInit | |
832 | self.SetUseBestVisual(useBestVisual) | |
833 | ||
7bf85405 RD |
834 | if redirect: |
835 | self.RedirectStdio(filename) | |
1e4a197e | 836 | |
7bf85405 RD |
837 | # this initializes wxWindows and then calls our OnInit |
838 | _wxStart(self.OnInit) | |
839 | ||
840 | ||
841 | def __del__(self): | |
842 | try: | |
843 | self.RestoreStdio() | |
844 | except: | |
845 | pass | |
846 | ||
2f90df85 RD |
847 | |
848 | def SetTopWindow(self, frame): | |
849 | if self.stdioWin: | |
850 | self.stdioWin.SetParent(frame) | |
2f90df85 RD |
851 | wxPyApp.SetTopWindow(self, frame) |
852 | ||
a1df7a95 | 853 | |
2f90df85 RD |
854 | def MainLoop(self): |
855 | wxPyApp.MainLoop(self) | |
856 | self.RestoreStdio() | |
857 | ||
a1df7a95 | 858 | |
7bf85405 RD |
859 | def RedirectStdio(self, filename): |
860 | if filename: | |
861 | sys.stdout = sys.stderr = open(filename, 'a') | |
862 | else: | |
1e4a197e | 863 | self.stdioWin = self.outputWindowClass() |
c856d372 | 864 | sys.stdout = sys.stderr = self.stdioWin |
7bf85405 | 865 | |
a1df7a95 | 866 | |
7bf85405 RD |
867 | def RestoreStdio(self): |
868 | sys.stdout, sys.stderr = self.saveStdio | |
c856d372 | 869 | |
7bf85405 | 870 | |
1e4a197e RD |
871 | # change from wxPyApp_ to wxApp_ |
872 | wxApp_GetMacDefaultEncodingIsPC = wxc.wxPyApp_GetMacDefaultEncodingIsPC | |
873 | wxApp_GetMacSupportPCMenuShortcuts = wxc.wxPyApp_GetMacSupportPCMenuShortcuts | |
874 | wxApp_GetMacAboutMenuItemId = wxc.wxPyApp_GetMacAboutMenuItemId | |
875 | wxApp_GetMacPreferencesMenuItemId = wxc.wxPyApp_GetMacPreferencesMenuItemId | |
876 | wxApp_GetMacExitMenuItemId = wxc.wxPyApp_GetMacExitMenuItemId | |
877 | wxApp_GetMacHelpMenuTitleName = wxc.wxPyApp_GetMacHelpMenuTitleName | |
878 | wxApp_SetMacDefaultEncodingIsPC = wxc.wxPyApp_SetMacDefaultEncodingIsPC | |
879 | wxApp_SetMacSupportPCMenuShortcuts = wxc.wxPyApp_SetMacSupportPCMenuShortcuts | |
880 | wxApp_SetMacAboutMenuItemId = wxc.wxPyApp_SetMacAboutMenuItemId | |
881 | wxApp_SetMacPreferencesMenuItemId = wxc.wxPyApp_SetMacPreferencesMenuItemId | |
882 | wxApp_SetMacExitMenuItemId = wxc.wxPyApp_SetMacExitMenuItemId | |
883 | wxApp_SetMacHelpMenuTitleName = wxc.wxPyApp_SetMacHelpMenuTitleName | |
884 | ||
885 | ||
6999b0d8 RD |
886 | #---------------------------------------------------------------------------- |
887 | ||
888 | class wxPySimpleApp(wxApp): | |
83b18bab RD |
889 | def __init__(self, flag=0): |
890 | wxApp.__init__(self, flag) | |
6999b0d8 | 891 | def OnInit(self): |
3fce70fb | 892 | wxInitAllImageHandlers() |
1e4a197e | 893 | return True |
7bf85405 | 894 | |
2f90df85 | 895 | |
f6bcfd97 BP |
896 | class wxPyWidgetTester(wxApp): |
897 | def __init__(self, size = (250, 100)): | |
898 | self.size = size | |
899 | wxApp.__init__(self, 0) | |
900 | ||
901 | def OnInit(self): | |
902 | self.frame = wxFrame(None, -1, "Widget Tester", pos=(0,0), size=self.size) | |
903 | self.SetTopWindow(self.frame) | |
1e4a197e | 904 | return True |
f6bcfd97 BP |
905 | |
906 | def SetWidget(self, widgetClass, *args): | |
907 | w = apply(widgetClass, (self.frame,) + args) | |
1e4a197e | 908 | self.frame.Show(True) |
f6bcfd97 | 909 | |
7bf85405 | 910 | #---------------------------------------------------------------------------- |
4acff284 RD |
911 | # DO NOT hold any other references to this object. This is how we |
912 | # know when to cleanup system resources that wxWin is holding. When | |
913 | # the sys module is unloaded, the refcount on sys.__wxPythonCleanup | |
914 | # goes to zero and it calls the wxApp_CleanUp function. | |
b1462dfa | 915 | |
c0fbf24b RD |
916 | class __wxPyCleanup: |
917 | def __init__(self): | |
918 | self.cleanup = wxc.wxApp_CleanUp | |
919 | def __del__(self): | |
920 | self.cleanup() | |
921 | ||
922 | sys.__wxPythonCleanup = __wxPyCleanup() | |
923 | ||
ef2060fa | 924 | ## # another possible solution, but it gets called too early... |
c0fbf24b RD |
925 | ## if sys.version[0] == '2': |
926 | ## import atexit | |
927 | ## atexit.register(wxc.wxApp_CleanUp) | |
928 | ## else: | |
929 | ## sys.exitfunc = wxc.wxApp_CleanUp | |
b1462dfa | 930 | |
9416aa89 RD |
931 | |
932 | #---------------------------------------------------------------------------- | |
8bf5d46e | 933 | #---------------------------------------------------------------------------- |