]>
Commit | Line | Data |
---|---|---|
7bf85405 RD |
1 | #---------------------------------------------------------------------------- |
2 | # Name: _extra.py | |
3 | # Purpose: This file is appended to the shadow class file generated | |
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 | |
203c2f9a RD |
134 | def EVT_SET_CURSOR(win, func): |
135 | win.Connect(-1, -1, wxEVT_SET_CURSOR, func) | |
136 | ||
3af4e610 RD |
137 | |
138 | ||
cf694132 RD |
139 | def EVT_IDLE(win, func): |
140 | win.Connect(-1, -1, wxEVT_IDLE, func) | |
141 | ||
bb0054cd RD |
142 | def EVT_UPDATE_UI(win, id, func): |
143 | win.Connect(id, -1, wxEVT_UPDATE_UI, func) | |
144 | ||
eb715945 RD |
145 | def EVT_UPDATE_UI_RANGE(win, id, id2, func): |
146 | win.Connect(id, id2, wxEVT_UPDATE_UI, func) | |
147 | ||
7bf85405 RD |
148 | |
149 | # Mouse Events | |
150 | def EVT_LEFT_DOWN(win, func): | |
151 | win.Connect(-1, -1, wxEVT_LEFT_DOWN, func) | |
152 | ||
153 | def EVT_LEFT_UP(win, func): | |
154 | win.Connect(-1, -1, wxEVT_LEFT_UP, func) | |
155 | ||
156 | def EVT_MIDDLE_DOWN(win, func): | |
157 | win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func) | |
158 | ||
159 | def EVT_MIDDLE_UP(win, func): | |
160 | win.Connect(-1, -1, wxEVT_MIDDLE_UP, func) | |
161 | ||
162 | def EVT_RIGHT_DOWN(win, func): | |
163 | win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func) | |
164 | ||
165 | def EVT_RIGHT_UP(win, func): | |
166 | win.Connect(-1, -1, wxEVT_RIGHT_UP, func) | |
167 | ||
168 | def EVT_MOTION(win, func): | |
169 | win.Connect(-1, -1, wxEVT_MOTION, func) | |
170 | ||
171 | def EVT_LEFT_DCLICK(win, func): | |
172 | win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func) | |
173 | ||
174 | def EVT_MIDDLE_DCLICK(win, func): | |
175 | win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func) | |
176 | ||
177 | def EVT_RIGHT_DCLICK(win, func): | |
178 | win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func) | |
179 | ||
180 | def EVT_LEAVE_WINDOW(win, func): | |
181 | win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func) | |
182 | ||
183 | def EVT_ENTER_WINDOW(win, func): | |
184 | win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func) | |
185 | ||
d1679124 RD |
186 | def EVT_MOUSEWHEEL(win, func): |
187 | win.Connect(-1, -1, wxEVT_MOUSEWHEEL, func) | |
7bf85405 RD |
188 | |
189 | # all mouse events | |
190 | def EVT_MOUSE_EVENTS(win, func): | |
191 | win.Connect(-1, -1, wxEVT_LEFT_DOWN, func) | |
192 | win.Connect(-1, -1, wxEVT_LEFT_UP, func) | |
193 | win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func) | |
194 | win.Connect(-1, -1, wxEVT_MIDDLE_UP, func) | |
195 | win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func) | |
196 | win.Connect(-1, -1, wxEVT_RIGHT_UP, func) | |
197 | win.Connect(-1, -1, wxEVT_MOTION, func) | |
198 | win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func) | |
199 | win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func) | |
200 | win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func) | |
201 | win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func) | |
202 | win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func) | |
203 | ||
6d26dc89 RD |
204 | def EVT_MOUSE_CAPTURE_CHANGED(win, func): |
205 | win.Connect(-1, -1, wxEVT_MOUSE_CAPTURE_CHANGED, func) | |
206 | ||
7bf85405 RD |
207 | # EVT_COMMAND |
208 | def EVT_COMMAND(win, id, cmd, func): | |
209 | win.Connect(id, -1, cmd, func) | |
210 | ||
211 | def EVT_COMMAND_RANGE(win, id1, id2, cmd, func): | |
212 | win.Connect(id1, id2, cmd, func) | |
213 | ||
26b9cf27 | 214 | |
7bf85405 RD |
215 | # Scrolling |
216 | def EVT_SCROLL(win, func): | |
83f3dd45 RD |
217 | win.Connect(-1, -1, wxEVT_SCROLL_TOP, func) |
218 | win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func) | |
219 | win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func) | |
220 | win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func) | |
221 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func) | |
222 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
223 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func) | |
26b9cf27 | 224 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE,func) |
83f3dd45 | 225 | win.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL, func) |
7bf85405 RD |
226 | |
227 | def EVT_SCROLL_TOP(win, func): | |
228 | win.Connect(-1, -1, wxEVT_SCROLL_TOP, func) | |
229 | ||
230 | def EVT_SCROLL_BOTTOM(win, func): | |
231 | win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func) | |
232 | ||
233 | def EVT_SCROLL_LINEUP(win, func): | |
234 | win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func) | |
235 | ||
236 | def EVT_SCROLL_LINEDOWN(win, func): | |
237 | win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func) | |
238 | ||
239 | def EVT_SCROLL_PAGEUP(win, func): | |
240 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func) | |
241 | ||
242 | def EVT_SCROLL_PAGEDOWN(win, func): | |
243 | win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
244 | ||
245 | def EVT_SCROLL_THUMBTRACK(win, func): | |
246 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func) | |
247 | ||
26b9cf27 RD |
248 | def EVT_SCROLL_THUMBRELEASE(win, func): |
249 | win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE, func) | |
250 | ||
83f3dd45 RD |
251 | def EVT_SCROLL_ENDSCROLL(win, func): |
252 | win.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL, func) | |
253 | ||
7bf85405 RD |
254 | |
255 | ||
256 | # Scrolling, with an id | |
257 | def EVT_COMMAND_SCROLL(win, id, func): | |
258 | win.Connect(id, -1, wxEVT_SCROLL_TOP, func) | |
259 | win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func) | |
260 | win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func) | |
261 | win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func) | |
262 | win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func) | |
263 | win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
264 | win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func) | |
26b9cf27 | 265 | win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE,func) |
83f3dd45 | 266 | win.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL, func) |
7bf85405 RD |
267 | |
268 | def EVT_COMMAND_SCROLL_TOP(win, id, func): | |
269 | win.Connect(id, -1, wxEVT_SCROLL_TOP, func) | |
270 | ||
271 | def EVT_COMMAND_SCROLL_BOTTOM(win, id, func): | |
272 | win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func) | |
273 | ||
274 | def EVT_COMMAND_SCROLL_LINEUP(win, id, func): | |
275 | win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func) | |
276 | ||
277 | def EVT_COMMAND_SCROLL_LINEDOWN(win, id, func): | |
278 | win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func) | |
279 | ||
280 | def EVT_COMMAND_SCROLL_PAGEUP(win, id, func): | |
281 | win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func) | |
282 | ||
283 | def EVT_COMMAND_SCROLL_PAGEDOWN(win, id, func): | |
284 | win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func) | |
285 | ||
286 | def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func): | |
287 | win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func) | |
288 | ||
26b9cf27 RD |
289 | def EVT_COMMAND_SCROLL_THUMBRELEASE(win, id, func): |
290 | win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE, func) | |
291 | ||
83f3dd45 RD |
292 | def EVT_COMMAND_SCROLL_ENDSCROLL(win, id, func): |
293 | win.Connect(id, -1, wxEVT_SCROLL_ENDSCROLL, func) | |
294 | ||
d426c97e RD |
295 | #--- |
296 | def EVT_SCROLLWIN(win, func): | |
26b9cf27 RD |
297 | win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) |
298 | win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
299 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
300 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
301 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
302 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
303 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
304 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func) | |
d426c97e RD |
305 | |
306 | def EVT_SCROLLWIN_TOP(win, func): | |
307 | win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) | |
308 | ||
309 | def EVT_SCROLLWIN_BOTTOM(win, func): | |
310 | win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
311 | ||
312 | def EVT_SCROLLWIN_LINEUP(win, func): | |
313 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
314 | ||
315 | def EVT_SCROLLWIN_LINEDOWN(win, func): | |
316 | win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
317 | ||
318 | def EVT_SCROLLWIN_PAGEUP(win, func): | |
319 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
320 | ||
321 | def EVT_SCROLLWIN_PAGEDOWN(win, func): | |
322 | win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
323 | ||
324 | def EVT_SCROLLWIN_THUMBTRACK(win, func): | |
325 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
326 | ||
26b9cf27 RD |
327 | def EVT_SCROLLWIN_THUMBRELEASE(win, func): |
328 | win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func) | |
329 | ||
d426c97e RD |
330 | |
331 | ||
332 | # Scrolling, with an id | |
333 | def EVT_COMMAND_SCROLLWIN(win, id, func): | |
26b9cf27 RD |
334 | win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) |
335 | win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
336 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
337 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
338 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
339 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
340 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
341 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func) | |
d426c97e RD |
342 | |
343 | def EVT_COMMAND_SCROLLWIN_TOP(win, id, func): | |
344 | win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) | |
345 | ||
346 | def EVT_COMMAND_SCROLLWIN_BOTTOM(win, id, func): | |
347 | win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM, func) | |
348 | ||
349 | def EVT_COMMAND_SCROLLWIN_LINEUP(win, id, func): | |
350 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP, func) | |
351 | ||
352 | def EVT_COMMAND_SCROLLWIN_LINEDOWN(win, id, func): | |
353 | win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN, func) | |
354 | ||
355 | def EVT_COMMAND_SCROLLWIN_PAGEUP(win, id, func): | |
356 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP, func) | |
357 | ||
358 | def EVT_COMMAND_SCROLLWIN_PAGEDOWN(win, id, func): | |
359 | win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) | |
360 | ||
361 | def EVT_COMMAND_SCROLLWIN_THUMBTRACK(win, id, func): | |
362 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) | |
7bf85405 | 363 | |
26b9cf27 RD |
364 | def EVT_COMMAND_SCROLLWIN_THUMBRELEASE(win, id, func): |
365 | win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func) | |
366 | ||
367 | ||
7bf85405 RD |
368 | # Convenience commands |
369 | def EVT_BUTTON(win, id, func): | |
370 | win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func) | |
371 | ||
372 | def EVT_CHECKBOX(win, id, func): | |
373 | win.Connect(id, -1, wxEVT_COMMAND_CHECKBOX_CLICKED, func) | |
374 | ||
375 | def EVT_CHOICE(win, id, func): | |
376 | win.Connect(id, -1, wxEVT_COMMAND_CHOICE_SELECTED, func) | |
377 | ||
378 | def EVT_LISTBOX(win, id, func): | |
379 | win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_SELECTED, func) | |
380 | ||
381 | def EVT_LISTBOX_DCLICK(win, id, func): | |
382 | win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, func) | |
383 | ||
384 | def EVT_TEXT(win, id, func): | |
385 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_UPDATED, func) | |
386 | ||
387 | def EVT_TEXT_ENTER(win, id, func): | |
388 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_ENTER, func) | |
389 | ||
c7e7022c RD |
390 | def EVT_TEXT_URL(win, id, func): |
391 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_URL, func) | |
392 | ||
00b6c4e3 RD |
393 | def EVT_TEXT_MAXLEN(win, id, func): |
394 | win.Connect(id, -1, wxEVT_COMMAND_TEXT_MAXLEN, func) | |
395 | ||
7bf85405 RD |
396 | def EVT_MENU(win, id, func): |
397 | win.Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED, func) | |
398 | ||
399 | def EVT_MENU_RANGE(win, id1, id2, func): | |
400 | win.Connect(id1, id2, wxEVT_COMMAND_MENU_SELECTED, func) | |
401 | ||
402 | def EVT_SLIDER(win, id, func): | |
403 | win.Connect(id, -1, wxEVT_COMMAND_SLIDER_UPDATED, func) | |
404 | ||
405 | def EVT_RADIOBOX(win, id, func): | |
406 | win.Connect(id, -1, wxEVT_COMMAND_RADIOBOX_SELECTED, func) | |
407 | ||
408 | def EVT_RADIOBUTTON(win, id, func): | |
409 | win.Connect(id, -1, wxEVT_COMMAND_RADIOBUTTON_SELECTED, func) | |
410 | ||
411 | def EVT_VLBOX(win, id, func): | |
412 | win.Connect(id, -1, wxEVT_COMMAND_VLBOX_SELECTED, func) | |
413 | ||
414 | def EVT_COMBOBOX(win, id, func): | |
415 | win.Connect(id, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, func) | |
416 | ||
417 | def EVT_TOOL(win, id, func): | |
418 | win.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED, func) | |
419 | ||
3af4e610 RD |
420 | def EVT_TOOL_RANGE(win, id, id2, func): |
421 | win.Connect(id, id2, wxEVT_COMMAND_TOOL_CLICKED, func) | |
422 | ||
7bf85405 RD |
423 | def EVT_TOOL_RCLICKED(win, id, func): |
424 | win.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED, func) | |
425 | ||
3af4e610 RD |
426 | def EVT_TOOL_RCLICKED_RANGE(win, id, id2, func): |
427 | win.Connect(id, id2, wxEVT_COMMAND_TOOL_RCLICKED, func) | |
428 | ||
7bf85405 RD |
429 | def EVT_TOOL_ENTER(win, id, func): |
430 | win.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER, func) | |
431 | ||
432 | def EVT_CHECKLISTBOX(win, id, func): | |
433 | win.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, func) | |
434 | ||
3af4e610 RD |
435 | def EVT_SPINCTRL(win, id, func): |
436 | win.Connect(id, -1, wxEVT_COMMAND_SPINCTRL_UPDATED, func) | |
437 | ||
438 | ||
7bf85405 RD |
439 | |
440 | # Generic command events | |
441 | ||
442 | def EVT_COMMAND_LEFT_CLICK(win, id, func): | |
443 | win.Connect(id, -1, wxEVT_COMMAND_LEFT_CLICK, func) | |
444 | ||
445 | def EVT_COMMAND_LEFT_DCLICK(win, id, func): | |
446 | win.Connect(id, -1, wxEVT_COMMAND_LEFT_DCLICK, func) | |
447 | ||
448 | def EVT_COMMAND_RIGHT_CLICK(win, id, func): | |
449 | win.Connect(id, -1, wxEVT_COMMAND_RIGHT_CLICK, func) | |
450 | ||
451 | def EVT_COMMAND_RIGHT_DCLICK(win, id, func): | |
452 | win.Connect(id, -1, wxEVT_COMMAND_RIGHT_DCLICK, func) | |
453 | ||
454 | def EVT_COMMAND_SET_FOCUS(win, id, func): | |
455 | win.Connect(id, -1, wxEVT_COMMAND_SET_FOCUS, func) | |
456 | ||
457 | def EVT_COMMAND_KILL_FOCUS(win, id, func): | |
458 | win.Connect(id, -1, wxEVT_COMMAND_KILL_FOCUS, func) | |
459 | ||
460 | def EVT_COMMAND_ENTER(win, id, func): | |
461 | win.Connect(id, -1, wxEVT_COMMAND_ENTER, func) | |
462 | ||
463 | ||
d5c9047a | 464 | # wxNotebook events |
7bf85405 RD |
465 | def EVT_NOTEBOOK_PAGE_CHANGED(win, id, func): |
466 | win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, func) | |
467 | ||
468 | def EVT_NOTEBOOK_PAGE_CHANGING(win, id, func): | |
469 | win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, func) | |
470 | ||
471 | ||
b639c3c5 | 472 | # wxSpinButton |
62bd0874 RD |
473 | def EVT_SPIN_UP(win, id, func): |
474 | win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func) | |
475 | ||
476 | def EVT_SPIN_DOWN(win, id, func): | |
f6bcfd97 | 477 | win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func) |
62bd0874 RD |
478 | |
479 | def EVT_SPIN(win, id, func): | |
62bd0874 RD |
480 | win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func) |
481 | ||
482 | ||
b639c3c5 RD |
483 | # wxTaskBarIcon |
484 | def EVT_TASKBAR_MOVE(win, func): | |
485 | win.Connect(-1, -1, wxEVT_TASKBAR_MOVE, func) | |
486 | ||
487 | def EVT_TASKBAR_LEFT_DOWN(win, func): | |
488 | win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DOWN, func) | |
489 | ||
490 | def EVT_TASKBAR_LEFT_UP(win, func): | |
491 | win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_UP, func) | |
492 | ||
493 | def EVT_TASKBAR_RIGHT_DOWN(win, func): | |
494 | win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DOWN, func) | |
495 | ||
496 | def EVT_TASKBAR_RIGHT_UP(win, func): | |
497 | win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_UP, func) | |
498 | ||
499 | def EVT_TASKBAR_LEFT_DCLICK(win, func): | |
500 | win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DCLICK, func) | |
501 | ||
502 | def EVT_TASKBAR_RIGHT_DCLICK(win, func): | |
503 | win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DCLICK, func) | |
504 | ||
505 | ||
08127323 RD |
506 | # wxSashWindow |
507 | def EVT_SASH_DRAGGED(win, id, func): | |
508 | win.Connect(id, -1, wxEVT_SASH_DRAGGED, func) | |
509 | ||
510 | def EVT_SASH_DRAGGED_RANGE(win, id1, id2, func): | |
511 | win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func) | |
512 | ||
513 | def EVT_QUERY_LAYOUT_INFO(win, func): | |
514 | win.Connect(-1, -1, wxEVT_EVT_QUERY_LAYOUT_INFO, func) | |
515 | ||
516 | def EVT_CALCULATE_LAYOUT(win, func): | |
517 | win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func) | |
518 | ||
519 | ||
bb0054cd RD |
520 | #wxSplitterWindow |
521 | def EVT_SPLITTER_SASH_POS_CHANGING(win, id, func): | |
522 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING, func) | |
523 | ||
524 | def EVT_SPLITTER_SASH_POS_CHANGED(win, id, func): | |
525 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED, func) | |
526 | ||
527 | def EVT_SPLITTER_UNSPLIT(win, id, func): | |
528 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_UNSPLIT, func) | |
529 | ||
530 | def EVT_SPLITTER_DOUBLECLICKED(win, id, func): | |
531 | win.Connect(id, -1, wxEVT_COMMAND_SPLITTER_DOUBLECLICKED, func) | |
532 | ||
b639c3c5 | 533 | |
f6bcfd97 BP |
534 | # wxTimer |
535 | def EVT_TIMER(win, id, func): | |
536 | win.Connect(id, -1, wxEVT_TIMER, func) | |
537 | ||
c368d904 RD |
538 | # wxProcess |
539 | def EVT_END_PROCESS(eh, id, func): | |
540 | eh.Connect(id, -1, wxEVT_END_PROCESS, func) | |
f6bcfd97 | 541 | |
185d7c3e RD |
542 | |
543 | # wxJoyStick | |
544 | def EVT_JOY_DOWN(win, func): | |
ac346f50 | 545 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_DOWN, func) |
185d7c3e RD |
546 | |
547 | def EVT_JOY_UP(win, func): | |
ac346f50 | 548 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_UP, func) |
185d7c3e RD |
549 | |
550 | def EVT_JOY_MOVE(win, func): | |
551 | win.Connect(-1, -1, wxEVT_JOY_MOVE, func) | |
552 | ||
553 | def EVT_JOY_ZMOVE(win, func): | |
554 | win.Connect(-1, -1, wxEVT_JOY_ZMOVE, func) | |
555 | ||
556 | def EVT_JOYSTICK_EVENTS(win, func): | |
ac346f50 RD |
557 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_DOWN, func) |
558 | win.Connect(-1, -1, wxEVT_JOY_BUTTON_UP, func) | |
185d7c3e RD |
559 | win.Connect(-1, -1, wxEVT_JOY_MOVE, func) |
560 | win.Connect(-1, -1, wxEVT_JOY_ZMOVE, func) | |
561 | ||
d1679124 RD |
562 | |
563 | def EVT_TOGGLEBUTTON(win, id, func): | |
564 | win.Connect(id, -1, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, func) | |
565 | ||
566 | ||
4f3449b4 | 567 | |
4f3449b4 RD |
568 | def EVT_CONTEXT_MENU(win, func): |
569 | win.Connect(-1, -1, wxEVT_CONTEXT_MENU, func) | |
570 | ||
571 | ||
9c039d08 | 572 | #---------------------------------------------------------------------- |
7bf85405 RD |
573 | |
574 | class wxTimer(wxPyTimer): | |
185d7c3e RD |
575 | def __init__(self, evtHandler = None, id = -1): |
576 | if evtHandler is None: | |
577 | wxPyTimer.__init__(self, self.Notify) # derived class must provide | |
578 | # Notify(self) method. | |
579 | else: | |
580 | wxPyTimer.__init__(self, None) | |
581 | self.SetOwner(evtHandler, id) | |
7bf85405 | 582 | |
7bf85405 RD |
583 | #---------------------------------------------------------------------- |
584 | # aliases | |
585 | ||
b639c3c5 | 586 | wxColor = wxColour |
7bf85405 | 587 | wxNamedColor = wxNamedColour |
ecc08ead | 588 | wxPen = wxPyPen |
293a0a86 RD |
589 | wxScrollbar = wxScrollBar |
590 | ||
af309447 | 591 | |
6999b0d8 | 592 | # backwards compatibility |
b68dc582 RD |
593 | wxNoRefBitmap = wxBitmap |
594 | wxPyDefaultPosition = wxDefaultPosition | |
595 | wxPyDefaultSize = wxDefaultSize | |
68320e40 RD |
596 | NULL = None |
597 | wxSystemSettings_GetSystemColour = wxSystemSettings_GetColour | |
598 | wxSystemSettings_GetSystemFont = wxSystemSettings_GetFont | |
599 | wxSystemSettings_GetSystemMetric = wxSystemSettings_GetMetric | |
00b6c4e3 | 600 | |
a3fbed81 | 601 | #---------------------------------------------------------------------- |
00b6c4e3 RD |
602 | # wxGTK sets the locale when initialized. Doing this at the Python |
603 | # level should set it up to match what GTK is doing at the C level. | |
293a0a86 RD |
604 | if wxPlatform == "__WXGTK__": |
605 | try: | |
606 | import locale | |
607 | locale.setlocale(locale.LC_ALL, "") | |
608 | except: | |
609 | pass | |
00b6c4e3 RD |
610 | |
611 | ||
a3fbed81 RD |
612 | |
613 | #---------------------------------------------------------------------- | |
614 | # wxWindows version numbers. wxPython version is in __version__. | |
615 | ||
616 | wxMAJOR_VERSION = wxc.wxMAJOR_VERSION | |
617 | wxMINOR_VERSION = wxc.wxMINOR_VERSION | |
618 | wxRELEASE_NUMBER = wxc.wxRELEASE_NUMBER | |
619 | wxVERSION_STRING = wxc.wxVERSION_STRING | |
620 | wxVERSION_NUMBER = wxc.wxVERSION_NUMBER | |
621 | ||
622 | wxVERSION = (wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER) | |
623 | ||
624 | ||
8bf5d46e RD |
625 | #---------------------------------------------------------------------- |
626 | # This helper function will take a wxPython object and convert it to | |
627 | # another wxPython object type. This will not be able to create objects | |
7bcd390c | 628 | # that are derived from wxPython classes by the user, only those that are |
8bf5d46e RD |
629 | # actually part of wxPython and directly corespond to C++ objects. |
630 | # | |
631 | # This is useful in situations where some method returns a generic | |
632 | # type such as wxWindow, but you know that it is actually some | |
633 | # derived type such as a wxTextCtrl. You can't call wxTextCtrl specific | |
634 | # methods on a wxWindow object, but you can use this function to | |
635 | # create a wxTextCtrl object that will pass the same pointer to | |
636 | # the C++ code. You use it like this: | |
637 | # | |
638 | # textCtrl = wxPyTypeCast(window, "wxTextCtrl") | |
639 | # | |
640 | # | |
641 | # WARNING: Using this function to type cast objects into types that | |
642 | # they are not is not recommended and is likely to cause your | |
643 | # program to crash... Hard. | |
644 | # | |
645 | ||
646 | def wxPyTypeCast(obj, typeStr): | |
83b18bab RD |
647 | if obj is None: |
648 | return None | |
9416aa89 RD |
649 | theClass = globals()[typeStr+"Ptr"] |
650 | typeStr = __wxPyPtrTypeMap.get(typeStr, typeStr) | |
8bf5d46e | 651 | if hasattr(obj, "this"): |
2aab8f16 RD |
652 | # if already the right type then just return it |
653 | if isinstance(obj, theClass) or obj.__class__ is theClass: | |
9416aa89 | 654 | return obj |
8bf5d46e RD |
655 | newPtr = ptrcast(obj.this, typeStr+"_p") |
656 | else: | |
657 | newPtr = ptrcast(obj, typeStr+"_p") | |
8bf5d46e | 658 | theObj = theClass(newPtr) |
6999b0d8 RD |
659 | if hasattr(obj, "this"): |
660 | theObj.thisown = obj.thisown | |
8bf5d46e RD |
661 | return theObj |
662 | ||
663 | ||
4acff284 | 664 | #---------------------------------------------------------------------------- |
72797a7d RD |
665 | _wxCallAfterId = None |
666 | ||
667 | def wxCallAfter(callable, *args, **kw): | |
668 | """ | |
669 | Call the specified function after the current and pending event | |
c2dac736 RD |
670 | handlers have been completed. This is also good for making GUI |
671 | method calls from non-GUI threads. | |
72797a7d RD |
672 | """ |
673 | app = wxGetApp() | |
674 | assert app, 'No wxApp created yet' | |
675 | ||
676 | global _wxCallAfterId | |
677 | if _wxCallAfterId is None: | |
678 | _wxCallAfterId = wxNewId() | |
679 | app.Connect(-1, -1, _wxCallAfterId, | |
680 | lambda event: apply(event.callable, event.args, event.kw) ) | |
681 | evt = wxPyEvent() | |
682 | evt.SetEventType(_wxCallAfterId) | |
683 | evt.callable = callable | |
684 | evt.args = args | |
685 | evt.kw = kw | |
686 | wxPostEvent(app, evt) | |
687 | ||
688 | #---------------------------------------------------------------------- | |
4acff284 | 689 | |
7cdaed0b RD |
690 | class wxPyDeadObjectError(AttributeError): |
691 | pass | |
4acff284 RD |
692 | |
693 | class _wxPyDeadObject: | |
694 | """ | |
695 | Instances of wx objects that are OOR capable will have their __class__ | |
696 | changed to this class when the C++ object is deleted. This should help | |
697 | prevent crashes due to referencing a bogus C++ pointer. | |
698 | """ | |
7cdaed0b | 699 | reprStr = "wxPython wrapper for DELETED %s object! (The C++ object no longer exists.)" |
fc51b8c3 | 700 | attrStr = "The C++ part of the %s object has been deleted, attribute access no longer allowed." |
7cdaed0b | 701 | |
4acff284 RD |
702 | def __repr__( self ): |
703 | if not hasattr(self, "_name"): | |
704 | self._name = "[unknown]" | |
7cdaed0b | 705 | return self.reprStr % self._name |
4acff284 RD |
706 | |
707 | def __getattr__( self, *args ): | |
708 | if not hasattr(self, "_name"): | |
709 | self._name = "[unknown]" | |
7cdaed0b RD |
710 | raise wxPyDeadObjectError( self.attrStr % self._name ) |
711 | ||
712 | def __nonzero__(self): | |
713 | return 0 | |
4acff284 RD |
714 | |
715 | ||
c856d372 | 716 | #---------------------------------------------------------------------- |
7bf85405 RD |
717 | #---------------------------------------------------------------------- |
718 | ||
2f90df85 RD |
719 | class wxPyOnDemandOutputWindow: |
720 | def __init__(self, title = "wxPython: stdout/stderr"): | |
721 | self.frame = None | |
722 | self.title = title | |
c856d372 | 723 | self.parent = None |
2f90df85 RD |
724 | |
725 | def SetParent(self, parent): | |
726 | self.parent = parent | |
cf694132 | 727 | |
2f90df85 RD |
728 | def OnCloseWindow(self, event): |
729 | if self.frame != None: | |
730 | self.frame.Destroy() | |
731 | self.frame = None | |
732 | self.text = None | |
7bf85405 | 733 | |
6e18ca6c | 734 | # These methods provide the file-like output behaviour. |
2f90df85 | 735 | def write(self, str): |
6e18ca6c RD |
736 | if not wxThread_IsMain(): |
737 | # Aquire the GUI mutex before making GUI calls. Mutex is released | |
03a2c062 | 738 | # when locker is deleted at the end of this function. |
6e18ca6c RD |
739 | locker = wxMutexGuiLocker() |
740 | ||
2f90df85 | 741 | if not self.frame: |
03a2c062 RD |
742 | self.frame = wxFrame(self.parent, -1, self.title, |
743 | style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE) | |
2f90df85 RD |
744 | self.text = wxTextCtrl(self.frame, -1, "", |
745 | style = wxTE_MULTILINE|wxTE_READONLY) | |
746 | self.frame.SetSize(wxSize(450, 300)) | |
747 | self.frame.Show(true) | |
748 | EVT_CLOSE(self.frame, self.OnCloseWindow) | |
749 | self.text.AppendText(str) | |
750 | ||
751 | def close(self): | |
a1df7a95 | 752 | if self.frame != None: |
6e18ca6c RD |
753 | if not wxThread_IsMain(): |
754 | locker = wxMutexGuiLocker() | |
c856d372 | 755 | self.frame.Close() |
7bf85405 | 756 | |
7bf85405 | 757 | |
606d919c | 758 | _defRedirect = (wxPlatform == '__WXMSW__' or wxPlatform == '__WXMAC__') |
7bf85405 RD |
759 | |
760 | #---------------------------------------------------------------------- | |
761 | # The main application class. Derive from this and implement an OnInit | |
762 | # method that creates a frame and then calls self.SetTopWindow(frame) | |
763 | ||
764 | class wxApp(wxPyApp): | |
765 | error = 'wxApp.error' | |
2f90df85 | 766 | outputWindowClass = wxPyOnDemandOutputWindow |
7bf85405 RD |
767 | |
768 | def __init__(self, redirect=_defRedirect, filename=None): | |
769 | wxPyApp.__init__(self) | |
770 | self.stdioWin = None | |
771 | self.saveStdio = (sys.stdout, sys.stderr) | |
772 | if redirect: | |
773 | self.RedirectStdio(filename) | |
7bf85405 RD |
774 | # this initializes wxWindows and then calls our OnInit |
775 | _wxStart(self.OnInit) | |
776 | ||
777 | ||
778 | def __del__(self): | |
779 | try: | |
780 | self.RestoreStdio() | |
781 | except: | |
782 | pass | |
783 | ||
2f90df85 RD |
784 | |
785 | def SetTopWindow(self, frame): | |
786 | if self.stdioWin: | |
787 | self.stdioWin.SetParent(frame) | |
2f90df85 RD |
788 | wxPyApp.SetTopWindow(self, frame) |
789 | ||
a1df7a95 | 790 | |
2f90df85 RD |
791 | def MainLoop(self): |
792 | wxPyApp.MainLoop(self) | |
793 | self.RestoreStdio() | |
794 | ||
a1df7a95 | 795 | |
7bf85405 RD |
796 | def RedirectStdio(self, filename): |
797 | if filename: | |
798 | sys.stdout = sys.stderr = open(filename, 'a') | |
799 | else: | |
2f90df85 | 800 | self.stdioWin = self.outputWindowClass() # wxPyOnDemandOutputWindow |
c856d372 | 801 | sys.stdout = sys.stderr = self.stdioWin |
7bf85405 | 802 | |
a1df7a95 | 803 | |
7bf85405 RD |
804 | def RestoreStdio(self): |
805 | sys.stdout, sys.stderr = self.saveStdio | |
c856d372 | 806 | |
7bf85405 | 807 | |
6999b0d8 RD |
808 | #---------------------------------------------------------------------------- |
809 | ||
810 | class wxPySimpleApp(wxApp): | |
83b18bab RD |
811 | def __init__(self, flag=0): |
812 | wxApp.__init__(self, flag) | |
6999b0d8 | 813 | def OnInit(self): |
3fce70fb | 814 | wxInitAllImageHandlers() |
6999b0d8 | 815 | return true |
7bf85405 | 816 | |
2f90df85 | 817 | |
f6bcfd97 BP |
818 | class wxPyWidgetTester(wxApp): |
819 | def __init__(self, size = (250, 100)): | |
820 | self.size = size | |
821 | wxApp.__init__(self, 0) | |
822 | ||
823 | def OnInit(self): | |
824 | self.frame = wxFrame(None, -1, "Widget Tester", pos=(0,0), size=self.size) | |
825 | self.SetTopWindow(self.frame) | |
826 | return true | |
827 | ||
828 | def SetWidget(self, widgetClass, *args): | |
829 | w = apply(widgetClass, (self.frame,) + args) | |
830 | self.frame.Show(true) | |
831 | ||
7bf85405 | 832 | #---------------------------------------------------------------------------- |
4acff284 RD |
833 | # DO NOT hold any other references to this object. This is how we |
834 | # know when to cleanup system resources that wxWin is holding. When | |
835 | # the sys module is unloaded, the refcount on sys.__wxPythonCleanup | |
836 | # goes to zero and it calls the wxApp_CleanUp function. | |
b1462dfa | 837 | |
c0fbf24b RD |
838 | class __wxPyCleanup: |
839 | def __init__(self): | |
840 | self.cleanup = wxc.wxApp_CleanUp | |
841 | def __del__(self): | |
842 | self.cleanup() | |
843 | ||
844 | sys.__wxPythonCleanup = __wxPyCleanup() | |
845 | ||
ef2060fa | 846 | ## # another possible solution, but it gets called too early... |
c0fbf24b RD |
847 | ## if sys.version[0] == '2': |
848 | ## import atexit | |
849 | ## atexit.register(wxc.wxApp_CleanUp) | |
850 | ## else: | |
851 | ## sys.exitfunc = wxc.wxApp_CleanUp | |
b1462dfa | 852 | |
9416aa89 RD |
853 | |
854 | #---------------------------------------------------------------------------- | |
8bf5d46e | 855 | #---------------------------------------------------------------------------- |