1 #----------------------------------------------------------------------------
3 # Purpose: This file is appended to the shadow class file generated
4 # by SWIG. We add some unSWIGable things here.
9 # Copyright: (c) 1998 by Total Control Software
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------------
15 #----------------------------------------------------------------------
16 # This gives this module's dictionary to the C++ extension code...
18 _wxSetDictionary(vars())
21 #----------------------------------------------------------------------
22 #----------------------------------------------------------------------
23 # Helper function to link python methods to wxWindows virtual
26 def _checkForCallback(obj
, name
, event
, theID
=-1):
27 try: cb
= getattr(obj
, name
)
29 else: obj
.Connect(theID
, -1, event
, cb
)
32 #----------------------------------------------------------------------
33 #----------------------------------------------------------------------
34 # functions that look and act like the C++ Macros of the same name
38 def EVT_SIZE(win
, func
):
39 win
.Connect(-1, -1, wxEVT_SIZE
, func
)
41 def EVT_MOVE(win
, func
):
42 win
.Connect(-1, -1, wxEVT_MOVE
, func
)
44 def EVT_SIZING(win
, func
):
45 win
.Connect(-1, -1, wxEVT_SIZING
, func
)
47 def EVT_MOVING(win
, func
):
48 win
.Connect(-1, -1, wxEVT_MOVING
, func
)
50 def EVT_CLOSE(win
, func
):
51 win
.Connect(-1, -1, wxEVT_CLOSE_WINDOW
, func
)
53 def EVT_PAINT(win
, func
):
54 win
.Connect(-1, -1, wxEVT_PAINT
, func
)
56 def EVT_ERASE_BACKGROUND(win
, func
):
57 win
.Connect(-1, -1, wxEVT_ERASE_BACKGROUND
, func
)
59 def EVT_CHAR(win
, func
):
60 win
.Connect(-1, -1, wxEVT_CHAR
, func
)
62 def EVT_CHAR_HOOK(win
, func
):
63 win
.Connect(-1, -1, wxEVT_CHAR_HOOK
, func
)
65 def EVT_KEY_DOWN(win
, func
):
66 win
.Connect(-1, -1, wxEVT_KEY_DOWN
, func
)
68 def EVT_KEY_UP(win
, func
):
69 win
.Connect(-1, -1, wxEVT_KEY_UP
, func
)
71 def EVT_HOTKEY(win
, func
):
72 win
.Connect(-1, -1, wxEVT_HOTKEY
, func
)
74 def EVT_MENU_OPEN(win
, func
):
75 win
.Connect(-1, -1, wxEVT_MENU_OPEN
, func
)
77 def EVT_MENU_CLOSE(win
, func
):
78 win
.Connect(-1, -1, wxEVT_MENU_CLOSE
, func
)
80 def EVT_MENU_HIGHLIGHT(win
, id, func
):
81 win
.Connect(id, -1, wxEVT_MENU_HIGHLIGHT
, func
)
83 def EVT_MENU_HIGHLIGHT_ALL(win
, func
):
84 win
.Connect(-1, -1, wxEVT_MENU_HIGHLIGHT
, func
)
86 def EVT_SET_FOCUS(win
, func
):
87 win
.Connect(-1, -1, wxEVT_SET_FOCUS
, func
)
89 def EVT_KILL_FOCUS(win
, func
):
90 win
.Connect(-1, -1, wxEVT_KILL_FOCUS
, func
)
92 def EVT_CHILD_FOCUS(win
, func
):
93 win
.Connect(-1, -1, wxEVT_CHILD_FOCUS
, func
)
95 def EVT_ACTIVATE(win
, func
):
96 win
.Connect(-1, -1, wxEVT_ACTIVATE
, func
)
98 def EVT_ACTIVATE_APP(win
, func
):
99 win
.Connect(-1, -1, wxEVT_ACTIVATE_APP
, func
)
101 def EVT_END_SESSION(win
, func
):
102 win
.Connect(-1, -1, wxEVT_END_SESSION
, func
)
104 def EVT_QUERY_END_SESSION(win
, func
):
105 win
.Connect(-1, -1, wxEVT_QUERY_END_SESSION
, func
)
107 def EVT_DROP_FILES(win
, func
):
108 win
.Connect(-1, -1, wxEVT_DROP_FILES
, func
)
110 def EVT_INIT_DIALOG(win
, func
):
111 win
.Connect(-1, -1, wxEVT_INIT_DIALOG
, func
)
113 def EVT_SYS_COLOUR_CHANGED(win
, func
):
114 win
.Connect(-1, -1, wxEVT_SYS_COLOUR_CHANGED
, func
)
116 def EVT_DISPLAY_CHANGED(win
, func
):
117 win
.Connect(-1, -1, wxEVT_DISPLAY_CHANGED
, func
)
119 def EVT_SHOW(win
, func
):
120 win
.Connect(-1, -1, wxEVT_SHOW
, func
)
122 def EVT_MAXIMIZE(win
, func
):
123 win
.Connect(-1, -1, wxEVT_MAXIMIZE
, func
)
125 def EVT_ICONIZE(win
, func
):
126 win
.Connect(-1, -1, wxEVT_ICONIZE
, func
)
128 def EVT_NAVIGATION_KEY(win
, func
):
129 win
.Connect(-1, -1, wxEVT_NAVIGATION_KEY
, func
)
131 def EVT_PALETTE_CHANGED(win
, func
):
132 win
.Connect(-1, -1, wxEVT_PALETTE_CHANGED
, func
)
134 def EVT_QUERY_NEW_PALETTE(win
, func
):
135 win
.Connect(-1, -1, wxEVT_QUERY_NEW_PALETTE
, func
)
137 def EVT_WINDOW_CREATE(win
, func
):
138 win
.Connect(-1, -1, wxEVT_CREATE
, func
)
140 def EVT_WINDOW_DESTROY(win
, func
):
141 win
.Connect(-1, -1, wxEVT_DESTROY
, func
)
143 def EVT_WINDOW_CREATE_ID(win
, id, func
):
144 win
.Connect(id, -1, wxEVT_CREATE
, func
)
146 def EVT_WINDOW_DESTROY_ID(win
, id, func
):
147 win
.Connect(id, -1, wxEVT_DESTROY
, func
)
149 def EVT_SET_CURSOR(win
, func
):
150 win
.Connect(-1, -1, wxEVT_SET_CURSOR
, func
)
154 def EVT_IDLE(win
, func
):
155 win
.Connect(-1, -1, wxEVT_IDLE
, func
)
157 def EVT_UPDATE_UI(win
, id, func
):
158 win
.Connect(id, -1, wxEVT_UPDATE_UI
, func
)
160 def EVT_UPDATE_UI_RANGE(win
, id, id2
, func
):
161 win
.Connect(id, id2
, wxEVT_UPDATE_UI
, func
)
165 def EVT_LEFT_DOWN(win
, func
):
166 win
.Connect(-1, -1, wxEVT_LEFT_DOWN
, func
)
168 def EVT_LEFT_UP(win
, func
):
169 win
.Connect(-1, -1, wxEVT_LEFT_UP
, func
)
171 def EVT_MIDDLE_DOWN(win
, func
):
172 win
.Connect(-1, -1, wxEVT_MIDDLE_DOWN
, func
)
174 def EVT_MIDDLE_UP(win
, func
):
175 win
.Connect(-1, -1, wxEVT_MIDDLE_UP
, func
)
177 def EVT_RIGHT_DOWN(win
, func
):
178 win
.Connect(-1, -1, wxEVT_RIGHT_DOWN
, func
)
180 def EVT_RIGHT_UP(win
, func
):
181 win
.Connect(-1, -1, wxEVT_RIGHT_UP
, func
)
183 def EVT_MOTION(win
, func
):
184 win
.Connect(-1, -1, wxEVT_MOTION
, func
)
186 def EVT_LEFT_DCLICK(win
, func
):
187 win
.Connect(-1, -1, wxEVT_LEFT_DCLICK
, func
)
189 def EVT_MIDDLE_DCLICK(win
, func
):
190 win
.Connect(-1, -1, wxEVT_MIDDLE_DCLICK
, func
)
192 def EVT_RIGHT_DCLICK(win
, func
):
193 win
.Connect(-1, -1, wxEVT_RIGHT_DCLICK
, func
)
195 def EVT_LEAVE_WINDOW(win
, func
):
196 win
.Connect(-1, -1, wxEVT_LEAVE_WINDOW
, func
)
198 def EVT_ENTER_WINDOW(win
, func
):
199 win
.Connect(-1, -1, wxEVT_ENTER_WINDOW
, func
)
201 def EVT_MOUSEWHEEL(win
, func
):
202 win
.Connect(-1, -1, wxEVT_MOUSEWHEEL
, func
)
205 def EVT_MOUSE_EVENTS(win
, func
):
206 win
.Connect(-1, -1, wxEVT_LEFT_DOWN
, func
)
207 win
.Connect(-1, -1, wxEVT_LEFT_UP
, func
)
208 win
.Connect(-1, -1, wxEVT_MIDDLE_DOWN
, func
)
209 win
.Connect(-1, -1, wxEVT_MIDDLE_UP
, func
)
210 win
.Connect(-1, -1, wxEVT_RIGHT_DOWN
, func
)
211 win
.Connect(-1, -1, wxEVT_RIGHT_UP
, func
)
212 win
.Connect(-1, -1, wxEVT_MOTION
, func
)
213 win
.Connect(-1, -1, wxEVT_LEFT_DCLICK
, func
)
214 win
.Connect(-1, -1, wxEVT_MIDDLE_DCLICK
, func
)
215 win
.Connect(-1, -1, wxEVT_RIGHT_DCLICK
, func
)
216 win
.Connect(-1, -1, wxEVT_LEAVE_WINDOW
, func
)
217 win
.Connect(-1, -1, wxEVT_ENTER_WINDOW
, func
)
219 def EVT_MOUSE_CAPTURE_CHANGED(win
, func
):
220 win
.Connect(-1, -1, wxEVT_MOUSE_CAPTURE_CHANGED
, func
)
223 def EVT_COMMAND(win
, id, cmd
, func
):
224 win
.Connect(id, -1, cmd
, func
)
226 def EVT_COMMAND_RANGE(win
, id1
, id2
, cmd
, func
):
227 win
.Connect(id1
, id2
, cmd
, func
)
231 def EVT_SCROLL(win
, func
):
232 win
.Connect(-1, -1, wxEVT_SCROLL_TOP
, func
)
233 win
.Connect(-1, -1, wxEVT_SCROLL_BOTTOM
, func
)
234 win
.Connect(-1, -1, wxEVT_SCROLL_LINEUP
, func
)
235 win
.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN
, func
)
236 win
.Connect(-1, -1, wxEVT_SCROLL_PAGEUP
, func
)
237 win
.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN
, func
)
238 win
.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK
, func
)
239 win
.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE
,func
)
240 win
.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL
, func
)
242 def EVT_SCROLL_TOP(win
, func
):
243 win
.Connect(-1, -1, wxEVT_SCROLL_TOP
, func
)
245 def EVT_SCROLL_BOTTOM(win
, func
):
246 win
.Connect(-1, -1, wxEVT_SCROLL_BOTTOM
, func
)
248 def EVT_SCROLL_LINEUP(win
, func
):
249 win
.Connect(-1, -1, wxEVT_SCROLL_LINEUP
, func
)
251 def EVT_SCROLL_LINEDOWN(win
, func
):
252 win
.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN
, func
)
254 def EVT_SCROLL_PAGEUP(win
, func
):
255 win
.Connect(-1, -1, wxEVT_SCROLL_PAGEUP
, func
)
257 def EVT_SCROLL_PAGEDOWN(win
, func
):
258 win
.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN
, func
)
260 def EVT_SCROLL_THUMBTRACK(win
, func
):
261 win
.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK
, func
)
263 def EVT_SCROLL_THUMBRELEASE(win
, func
):
264 win
.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE
, func
)
266 def EVT_SCROLL_ENDSCROLL(win
, func
):
267 win
.Connect(-1, -1, wxEVT_SCROLL_ENDSCROLL
, func
)
271 # Scrolling, with an id
272 def EVT_COMMAND_SCROLL(win
, id, func
):
273 win
.Connect(id, -1, wxEVT_SCROLL_TOP
, func
)
274 win
.Connect(id, -1, wxEVT_SCROLL_BOTTOM
, func
)
275 win
.Connect(id, -1, wxEVT_SCROLL_LINEUP
, func
)
276 win
.Connect(id, -1, wxEVT_SCROLL_LINEDOWN
, func
)
277 win
.Connect(id, -1, wxEVT_SCROLL_PAGEUP
, func
)
278 win
.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN
, func
)
279 win
.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK
,func
)
280 win
.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE
,func
)
281 win
.Connect(id, -1, wxEVT_SCROLL_ENDSCROLL
, func
)
283 def EVT_COMMAND_SCROLL_TOP(win
, id, func
):
284 win
.Connect(id, -1, wxEVT_SCROLL_TOP
, func
)
286 def EVT_COMMAND_SCROLL_BOTTOM(win
, id, func
):
287 win
.Connect(id, -1, wxEVT_SCROLL_BOTTOM
, func
)
289 def EVT_COMMAND_SCROLL_LINEUP(win
, id, func
):
290 win
.Connect(id, -1, wxEVT_SCROLL_LINEUP
, func
)
292 def EVT_COMMAND_SCROLL_LINEDOWN(win
, id, func
):
293 win
.Connect(id, -1, wxEVT_SCROLL_LINEDOWN
, func
)
295 def EVT_COMMAND_SCROLL_PAGEUP(win
, id, func
):
296 win
.Connect(id, -1, wxEVT_SCROLL_PAGEUP
, func
)
298 def EVT_COMMAND_SCROLL_PAGEDOWN(win
, id, func
):
299 win
.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN
, func
)
301 def EVT_COMMAND_SCROLL_THUMBTRACK(win
, id, func
):
302 win
.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK
, func
)
304 def EVT_COMMAND_SCROLL_THUMBRELEASE(win
, id, func
):
305 win
.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE
, func
)
307 def EVT_COMMAND_SCROLL_ENDSCROLL(win
, id, func
):
308 win
.Connect(id, -1, wxEVT_SCROLL_ENDSCROLL
, func
)
311 def EVT_SCROLLWIN(win
, func
):
312 win
.Connect(-1, -1, wxEVT_SCROLLWIN_TOP
, func
)
313 win
.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM
, func
)
314 win
.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP
, func
)
315 win
.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN
, func
)
316 win
.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP
, func
)
317 win
.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN
, func
)
318 win
.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK
, func
)
319 win
.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE
,func
)
321 def EVT_SCROLLWIN_TOP(win
, func
):
322 win
.Connect(-1, -1, wxEVT_SCROLLWIN_TOP
, func
)
324 def EVT_SCROLLWIN_BOTTOM(win
, func
):
325 win
.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM
, func
)
327 def EVT_SCROLLWIN_LINEUP(win
, func
):
328 win
.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP
, func
)
330 def EVT_SCROLLWIN_LINEDOWN(win
, func
):
331 win
.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN
, func
)
333 def EVT_SCROLLWIN_PAGEUP(win
, func
):
334 win
.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP
, func
)
336 def EVT_SCROLLWIN_PAGEDOWN(win
, func
):
337 win
.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN
, func
)
339 def EVT_SCROLLWIN_THUMBTRACK(win
, func
):
340 win
.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK
, func
)
342 def EVT_SCROLLWIN_THUMBRELEASE(win
, func
):
343 win
.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE
, func
)
347 # Scrolling, with an id
348 def EVT_COMMAND_SCROLLWIN(win
, id, func
):
349 win
.Connect(id, -1, wxEVT_SCROLLWIN_TOP
, func
)
350 win
.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM
, func
)
351 win
.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP
, func
)
352 win
.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN
, func
)
353 win
.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP
, func
)
354 win
.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN
, func
)
355 win
.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK
, func
)
356 win
.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE
,func
)
358 def EVT_COMMAND_SCROLLWIN_TOP(win
, id, func
):
359 win
.Connect(id, -1, wxEVT_SCROLLWIN_TOP
, func
)
361 def EVT_COMMAND_SCROLLWIN_BOTTOM(win
, id, func
):
362 win
.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM
, func
)
364 def EVT_COMMAND_SCROLLWIN_LINEUP(win
, id, func
):
365 win
.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP
, func
)
367 def EVT_COMMAND_SCROLLWIN_LINEDOWN(win
, id, func
):
368 win
.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN
, func
)
370 def EVT_COMMAND_SCROLLWIN_PAGEUP(win
, id, func
):
371 win
.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP
, func
)
373 def EVT_COMMAND_SCROLLWIN_PAGEDOWN(win
, id, func
):
374 win
.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN
, func
)
376 def EVT_COMMAND_SCROLLWIN_THUMBTRACK(win
, id, func
):
377 win
.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK
, func
)
379 def EVT_COMMAND_SCROLLWIN_THUMBRELEASE(win
, id, func
):
380 win
.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE
, func
)
383 # Convenience commands
384 def EVT_BUTTON(win
, id, func
):
385 win
.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED
, func
)
387 def EVT_CHECKBOX(win
, id, func
):
388 win
.Connect(id, -1, wxEVT_COMMAND_CHECKBOX_CLICKED
, func
)
390 def EVT_CHOICE(win
, id, func
):
391 win
.Connect(id, -1, wxEVT_COMMAND_CHOICE_SELECTED
, func
)
393 def EVT_LISTBOX(win
, id, func
):
394 win
.Connect(id, -1, wxEVT_COMMAND_LISTBOX_SELECTED
, func
)
396 def EVT_LISTBOX_DCLICK(win
, id, func
):
397 win
.Connect(id, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, func
)
399 def EVT_TEXT(win
, id, func
):
400 win
.Connect(id, -1, wxEVT_COMMAND_TEXT_UPDATED
, func
)
402 def EVT_TEXT_ENTER(win
, id, func
):
403 win
.Connect(id, -1, wxEVT_COMMAND_TEXT_ENTER
, func
)
405 def EVT_TEXT_URL(win
, id, func
):
406 win
.Connect(id, -1, wxEVT_COMMAND_TEXT_URL
, func
)
408 def EVT_TEXT_MAXLEN(win
, id, func
):
409 win
.Connect(id, -1, wxEVT_COMMAND_TEXT_MAXLEN
, func
)
411 def EVT_MENU(win
, id, func
):
412 win
.Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED
, func
)
414 def EVT_MENU_RANGE(win
, id1
, id2
, func
):
415 win
.Connect(id1
, id2
, wxEVT_COMMAND_MENU_SELECTED
, func
)
417 def EVT_SLIDER(win
, id, func
):
418 win
.Connect(id, -1, wxEVT_COMMAND_SLIDER_UPDATED
, func
)
420 def EVT_RADIOBOX(win
, id, func
):
421 win
.Connect(id, -1, wxEVT_COMMAND_RADIOBOX_SELECTED
, func
)
423 def EVT_RADIOBUTTON(win
, id, func
):
424 win
.Connect(id, -1, wxEVT_COMMAND_RADIOBUTTON_SELECTED
, func
)
426 def EVT_VLBOX(win
, id, func
):
427 win
.Connect(id, -1, wxEVT_COMMAND_VLBOX_SELECTED
, func
)
429 def EVT_COMBOBOX(win
, id, func
):
430 win
.Connect(id, -1, wxEVT_COMMAND_COMBOBOX_SELECTED
, func
)
432 def EVT_TOOL(win
, id, func
):
433 win
.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED
, func
)
435 def EVT_TOOL_RANGE(win
, id, id2
, func
):
436 win
.Connect(id, id2
, wxEVT_COMMAND_TOOL_CLICKED
, func
)
438 def EVT_TOOL_RCLICKED(win
, id, func
):
439 win
.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED
, func
)
441 def EVT_TOOL_RCLICKED_RANGE(win
, id, id2
, func
):
442 win
.Connect(id, id2
, wxEVT_COMMAND_TOOL_RCLICKED
, func
)
444 def EVT_TOOL_ENTER(win
, id, func
):
445 win
.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER
, func
)
447 def EVT_CHECKLISTBOX(win
, id, func
):
448 win
.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, func
)
450 def EVT_SPINCTRL(win
, id, func
):
451 win
.Connect(id, -1, wxEVT_COMMAND_SPINCTRL_UPDATED
, func
)
455 # Generic command events
457 def EVT_COMMAND_LEFT_CLICK(win
, id, func
):
458 win
.Connect(id, -1, wxEVT_COMMAND_LEFT_CLICK
, func
)
460 def EVT_COMMAND_LEFT_DCLICK(win
, id, func
):
461 win
.Connect(id, -1, wxEVT_COMMAND_LEFT_DCLICK
, func
)
463 def EVT_COMMAND_RIGHT_CLICK(win
, id, func
):
464 win
.Connect(id, -1, wxEVT_COMMAND_RIGHT_CLICK
, func
)
466 def EVT_COMMAND_RIGHT_DCLICK(win
, id, func
):
467 win
.Connect(id, -1, wxEVT_COMMAND_RIGHT_DCLICK
, func
)
469 def EVT_COMMAND_SET_FOCUS(win
, id, func
):
470 win
.Connect(id, -1, wxEVT_COMMAND_SET_FOCUS
, func
)
472 def EVT_COMMAND_KILL_FOCUS(win
, id, func
):
473 win
.Connect(id, -1, wxEVT_COMMAND_KILL_FOCUS
, func
)
475 def EVT_COMMAND_ENTER(win
, id, func
):
476 win
.Connect(id, -1, wxEVT_COMMAND_ENTER
, func
)
480 def EVT_SPIN_UP(win
, id, func
):
481 win
.Connect(id, -1, wxEVT_SCROLL_LINEUP
, func
)
483 def EVT_SPIN_DOWN(win
, id, func
):
484 win
.Connect(id, -1, wxEVT_SCROLL_LINEDOWN
, func
)
486 def EVT_SPIN(win
, id, func
):
487 win
.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK
,func
)
491 def EVT_SASH_DRAGGED(win
, id, func
):
492 win
.Connect(id, -1, wxEVT_SASH_DRAGGED
, func
)
494 def EVT_SASH_DRAGGED_RANGE(win
, id1
, id2
, func
):
495 win
.Connect(id1
, id2
, wxEVT_SASH_DRAGGED
, func
)
497 def EVT_QUERY_LAYOUT_INFO(win
, func
):
498 win
.Connect(-1, -1, wxEVT_QUERY_LAYOUT_INFO
, func
)
500 def EVT_CALCULATE_LAYOUT(win
, func
):
501 win
.Connect(-1, -1, wxEVT_CALCULATE_LAYOUT
, func
)
505 def EVT_SPLITTER_SASH_POS_CHANGING(win
, id, func
):
506 win
.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING
, func
)
508 def EVT_SPLITTER_SASH_POS_CHANGED(win
, id, func
):
509 win
.Connect(id, -1, wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
, func
)
511 def EVT_SPLITTER_UNSPLIT(win
, id, func
):
512 win
.Connect(id, -1, wxEVT_COMMAND_SPLITTER_UNSPLIT
, func
)
514 def EVT_SPLITTER_DOUBLECLICKED(win
, id, func
):
515 win
.Connect(id, -1, wxEVT_COMMAND_SPLITTER_DOUBLECLICKED
, func
)
519 def EVT_TIMER(win
, id, func
):
520 win
.Connect(id, -1, wxEVT_TIMER
, func
)
523 def EVT_END_PROCESS(eh
, id, func
):
524 eh
.Connect(id, -1, wxEVT_END_PROCESS
, func
)
528 def EVT_JOY_DOWN(win
, func
):
529 win
.Connect(-1, -1, wxEVT_JOY_BUTTON_DOWN
, func
)
531 def EVT_JOY_UP(win
, func
):
532 win
.Connect(-1, -1, wxEVT_JOY_BUTTON_UP
, func
)
534 def EVT_JOY_MOVE(win
, func
):
535 win
.Connect(-1, -1, wxEVT_JOY_MOVE
, func
)
537 def EVT_JOY_ZMOVE(win
, func
):
538 win
.Connect(-1, -1, wxEVT_JOY_ZMOVE
, func
)
540 def EVT_JOYSTICK_EVENTS(win
, func
):
541 win
.Connect(-1, -1, wxEVT_JOY_BUTTON_DOWN
, func
)
542 win
.Connect(-1, -1, wxEVT_JOY_BUTTON_UP
, func
)
543 win
.Connect(-1, -1, wxEVT_JOY_MOVE
, func
)
544 win
.Connect(-1, -1, wxEVT_JOY_ZMOVE
, func
)
547 def EVT_TOGGLEBUTTON(win
, id, func
):
548 win
.Connect(id, -1, wxEVT_COMMAND_TOGGLEBUTTON_CLICKED
, func
)
552 def EVT_CONTEXT_MENU(win
, func
):
553 win
.Connect(-1, -1, wxEVT_CONTEXT_MENU
, func
)
556 #----------------------------------------------------------------------
558 class wxTimer(wxPyTimer
):
559 def __init__(self
, evtHandler
= None, id = -1):
560 if evtHandler
is None:
561 wxPyTimer
.__init
__(self
, self
.Notify
) # derived class must provide
562 # Notify(self) method.
564 wxPyTimer
.__init
__(self
, None)
565 self
.SetOwner(evtHandler
, id)
567 #----------------------------------------------------------------------
571 wxNamedColor
= wxNamedColour
573 wxScrollbar
= wxScrollBar
574 wxPoint2D
= wxPoint2DDouble
576 wxPyAssertionError
= wxc
.wxPyAssertionError
579 # backwards compatibility
580 wxNoRefBitmap
= wxBitmap
581 wxPyDefaultPosition
= wxDefaultPosition
582 wxPyDefaultSize
= wxDefaultSize
584 wxSystemSettings_GetSystemColour
= wxSystemSettings_GetColour
585 wxSystemSettings_GetSystemFont
= wxSystemSettings_GetFont
586 wxSystemSettings_GetSystemMetric
= wxSystemSettings_GetMetric
589 # workarounds for bad wxRTTI names
590 __wxPyPtrTypeMap
['wxGauge95'] = 'wxGauge'
591 __wxPyPtrTypeMap
['wxSlider95'] = 'wxSlider'
592 __wxPyPtrTypeMap
['wxStatusBar95'] = 'wxStatusBar'
598 warnings
.warn("Use wxNewId instead", DeprecationWarning, 2)
603 warnings
.warn("Use wxRegisterId instead", DeprecationWarning, 2)
604 return wxRegisterId(ID
)
608 # Use Python's bool constants if available, make aliases if not
615 # Backwards compaatible
617 FALSE
= false
= False
620 #----------------------------------------------------------------------
621 # wxGTK sets the locale when initialized. Doing this at the Python
622 # level should set it up to match what GTK is doing at the C level.
623 if wxPlatform
== "__WXGTK__":
626 locale
.setlocale(locale
.LC_ALL
, "")
630 # On MSW add the directory where the wxWindows catalogs were installed
631 # to the default catalog path.
632 if wxPlatform
== "__WXMSW__":
634 localedir
= os
.path
.join(os
.path
.split(__file__
)[0], "locale")
635 wxLocale_AddCatalogLookupPathPrefix(localedir
)
638 #----------------------------------------------------------------------
639 # Load version numbers from __version__... Ensure that major and minor
640 # versions are the same for both wxPython and wxWindows.
642 from wxPython
.__version
__ import *
643 __version__
= wxVERSION_STRING
645 assert wxMAJOR_VERSION
== wxc
.wxMAJOR_VERSION
, "wxPython/wxWindows version mismatch"
646 assert wxMINOR_VERSION
== wxc
.wxMINOR_VERSION
, "wxPython/wxWindows version mismatch"
647 if wxRELEASE_VERSION
!= wxc
.wxRELEASE_VERSION
:
649 warnings
.warn("wxPython/wxWindows release number mismatch")
652 #----------------------------------------------------------------------
653 # This helper function will take a wxPython object and convert it to
654 # another wxPython object type. This will not be able to create objects
655 # that are derived from wxPython classes by the user, only those that are
656 # actually part of wxPython and directly corespond to C++ objects.
658 # This is useful in situations where some method returns a generic
659 # type such as wxWindow, but you know that it is actually some
660 # derived type such as a wxTextCtrl. You can't call wxTextCtrl specific
661 # methods on a wxWindow object, but you can use this function to
662 # create a wxTextCtrl object that will pass the same pointer to
663 # the C++ code. You use it like this:
665 # textCtrl = wxPyTypeCast(window, "wxTextCtrl")
668 # WARNING: Using this function to type cast objects into types that
669 # they are not is not recommended and is likely to cause your
670 # program to crash... Hard.
673 def wxPyTypeCast(obj
, typeStr
):
676 theClass
= globals()[typeStr
+"Ptr"]
677 typeStr
= __wxPyPtrTypeMap
.get(typeStr
, typeStr
)
678 if hasattr(obj
, "this"):
679 # if already the right type then just return it
680 if isinstance(obj
, theClass
) or obj
.__class
__ is theClass
:
682 newPtr
= ptrcast(obj
.this
, typeStr
+"_p")
684 newPtr
= ptrcast(obj
, typeStr
+"_p")
685 theObj
= theClass(newPtr
)
686 if hasattr(obj
, "this"):
687 theObj
.thisown
= obj
.thisown
690 #----------------------------------------------------------------------------
691 # An isinstance for Pythons < 2.2 that can check a sequence of class objects
692 # like the one in 2.2 can.
694 def wxPy_isinstance(obj
, klasses
):
696 if sys
.version
[:3] < "2.2" and type(klasses
) in [types
.TupleType
, types
.ListType
]:
697 for klass
in klasses
:
698 if isinstance(obj
, klass
): return True
701 return isinstance(obj
, klasses
)
703 #----------------------------------------------------------------------------
704 _wxCallAfterId
= None
706 def wxCallAfter(callable, *args
, **kw
):
708 Call the specified function after the current and pending event
709 handlers have been completed. This is also good for making GUI
710 method calls from non-GUI threads.
713 assert app
, 'No wxApp created yet'
715 global _wxCallAfterId
716 if _wxCallAfterId
is None:
717 _wxCallAfterId
= wxNewEventType()
718 app
.Connect(-1, -1, _wxCallAfterId
,
719 lambda event
: event
.callable(*event
.args
, **event
.kw
) )
721 evt
.SetEventType(_wxCallAfterId
)
722 evt
.callable = callable
725 wxPostEvent(app
, evt
)
728 #----------------------------------------------------------------------
733 A convenience class for wxTimer, that calls the given callable
734 object once after the given amount of milliseconds, passing any
735 positional or keyword args. The return value of the callable is
736 availbale after it has been run with the GetResult method.
738 If you don't need to get the return value or restart the timer
739 then there is no need to hold a reference to this object. It will
740 hold a reference to itself while the timer is running (the timer
741 has a reference to self.Notify) but the cycle will be broken when
742 the timer completes, automatically cleaning up the wxFutureCall
745 def __init__(self
, millis
, callable, *args
, **kwargs
):
747 self
.callable = callable
748 self
.SetArgs(*args
, **kwargs
)
759 def Start(self
, millis
=None):
764 if millis
is not None:
767 self
.timer
= wxPyTimer(self
.Notify
)
768 self
.timer
.Start(self
.millis
, wxTIMER_ONE_SHOT
)
774 Stop and destroy the timer.
776 if self
.timer
is not None:
781 def GetInterval(self
):
782 if self
.timer
is not None:
783 return self
.timer
.GetInterval()
789 return self
.timer
is not None and self
.timer
.IsRunning()
792 def SetArgs(self
, *args
, **kwargs
):
794 (Re)set the args passed to the callable object. This is
795 useful in conjunction with Restart if you want to schedule a
796 new call to the same callable object but with different
810 The timer has expired so call the callable.
812 if self
.callable and getattr(self
.callable, 'im_self', True):
814 self
.result
= self
.callable(*self
.args
, **self
.kwargs
)
816 wxCallAfter(self
.Stop
)
819 #----------------------------------------------------------------------
821 class wxPyDeadObjectError(AttributeError):
824 class _wxPyDeadObject
:
826 Instances of wx objects that are OOR capable will have their __class__
827 changed to this class when the C++ object is deleted. This should help
828 prevent crashes due to referencing a bogus C++ pointer.
830 reprStr
= "wxPython wrapper for DELETED %s object! (The C++ object no longer exists.)"
831 attrStr
= "The C++ part of the %s object has been deleted, attribute access no longer allowed."
833 def __repr__( self
):
834 if not hasattr(self
, "_name"):
835 self
._name
= "[unknown]"
836 return self
.reprStr
% self
._name
838 def __getattr__( self
, *args
):
839 if not hasattr(self
, "_name"):
840 self
._name
= "[unknown]"
841 raise wxPyDeadObjectError( self
.attrStr
% self
._name
)
843 def __nonzero__(self
):
847 #----------------------------------------------------------------------
849 class wxNotebookPage(wxPanel
):
851 There is an old (and apparently unsolvable) bug when placing a
852 window with a nonstandard background colour in a wxNotebook on
853 wxGTK, as the notbooks's background colour would always be used
854 when the window is refreshed. The solution is to place a panel in
855 the notbook and the coloured window on the panel, sized to cover
856 the panel. This simple class does that for you, just put an
857 instance of this in the notebook and make your regular window a
858 child of this one and it will handle the resize for you.
860 def __init__(self
, parent
, id=-1,
861 pos
=wxDefaultPosition
, size
=wxDefaultSize
,
862 style
=wxTAB_TRAVERSAL
, name
="panel"):
863 wxPanel
.__init
__(self
, parent
, id, pos
, size
, style
, name
)
865 EVT_SIZE(self
, self
.OnSize
)
866 def OnSize(self
, evt
):
867 if self
.child
is None:
868 children
= self
.GetChildren()
870 self
.child
= children
[0]
872 self
.child
.SetPosition((0,0))
873 self
.child
.SetSize(self
.GetSize())
876 #----------------------------------------------------------------------
877 #----------------------------------------------------------------------
879 class wxPyOnDemandOutputWindow
:
880 def __init__(self
, title
= "wxPython: stdout/stderr"):
885 def SetParent(self
, parent
):
888 def OnCloseWindow(self
, event
):
889 if self
.frame
!= None:
894 # These methods provide the file-like output behaviour.
895 def write(self
, str):
896 if not wxThread_IsMain():
897 # Aquire the GUI mutex before making GUI calls. Mutex is released
898 # when locker is deleted at the end of this function.
899 locker
= wxMutexGuiLocker()
902 self
.frame
= wxFrame(self
.parent
, -1, self
.title
,
903 style
=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE
)
904 self
.text
= wxTextCtrl(self
.frame
, -1, "",
905 style
= wxTE_MULTILINE|wxTE_READONLY
)
906 self
.frame
.SetSize(wxSize(450, 300))
907 self
.frame
.Show(True)
908 EVT_CLOSE(self
.frame
, self
.OnCloseWindow
)
909 self
.text
.AppendText(str)
912 if self
.frame
!= None:
913 if not wxThread_IsMain():
914 locker
= wxMutexGuiLocker()
918 _defRedirect
= (wxPlatform
== '__WXMSW__' or wxPlatform
== '__WXMAC__')
920 #----------------------------------------------------------------------
921 # The main application class. Derive from this and implement an OnInit
922 # method that creates a frame and then calls self.SetTopWindow(frame)
924 class wxApp(wxPyApp
):
925 error
= 'wxApp.error'
926 outputWindowClass
= wxPyOnDemandOutputWindow
928 def __init__(self
, redirect
=_defRedirect
, filename
=None, useBestVisual
=False):
929 wxPyApp
.__init
__(self
)
931 if wx
.wxPlatform
== "__WXMAC__":
934 if not MacOS
.WMAvailable():
935 print """This program needs access to the screen. Please run with
936 'pythonw', not 'python', and only when you are logged in on the main display
943 self
.saveStdio
= (sys
.stdout
, sys
.stderr
)
945 # This has to be done before OnInit
946 self
.SetUseBestVisual(useBestVisual
)
949 self
.RedirectStdio(filename
)
951 # Set the default handler for SIGINT. This fixes a problem
952 # where if Ctrl-C is pressed in the console that started this
953 # app then it will not appear to do anything, (not even send
954 # KeyboardInterrupt???) but will later segfault on exit. By
955 # setting the default handler then the app will exit, as
956 # expected (depending on platform.)
958 signal
.signal(signal
.SIGINT
, signal
.SIG_DFL
)
960 # this initializes wxWindows and then calls our OnInit
961 _wxStart(self
.OnInit
)
971 def SetTopWindow(self
, frame
):
973 self
.stdioWin
.SetParent(frame
)
974 wxPyApp
.SetTopWindow(self
, frame
)
978 wxPyApp
.MainLoop(self
)
982 def RedirectStdio(self
, filename
):
984 sys
.stdout
= sys
.stderr
= open(filename
, 'a')
986 self
.stdioWin
= self
.outputWindowClass()
987 sys
.stdout
= sys
.stderr
= self
.stdioWin
990 def RestoreStdio(self
):
991 sys
.stdout
, sys
.stderr
= self
.saveStdio
994 # change from wxPyApp_ to wxApp_
995 wxApp_GetMacDefaultEncodingIsPC
= wxc
.wxPyApp_GetMacDefaultEncodingIsPC
996 wxApp_GetMacSupportPCMenuShortcuts
= wxc
.wxPyApp_GetMacSupportPCMenuShortcuts
997 wxApp_GetMacAboutMenuItemId
= wxc
.wxPyApp_GetMacAboutMenuItemId
998 wxApp_GetMacPreferencesMenuItemId
= wxc
.wxPyApp_GetMacPreferencesMenuItemId
999 wxApp_GetMacExitMenuItemId
= wxc
.wxPyApp_GetMacExitMenuItemId
1000 wxApp_GetMacHelpMenuTitleName
= wxc
.wxPyApp_GetMacHelpMenuTitleName
1001 wxApp_SetMacDefaultEncodingIsPC
= wxc
.wxPyApp_SetMacDefaultEncodingIsPC
1002 wxApp_SetMacSupportPCMenuShortcuts
= wxc
.wxPyApp_SetMacSupportPCMenuShortcuts
1003 wxApp_SetMacAboutMenuItemId
= wxc
.wxPyApp_SetMacAboutMenuItemId
1004 wxApp_SetMacPreferencesMenuItemId
= wxc
.wxPyApp_SetMacPreferencesMenuItemId
1005 wxApp_SetMacExitMenuItemId
= wxc
.wxPyApp_SetMacExitMenuItemId
1006 wxApp_SetMacHelpMenuTitleName
= wxc
.wxPyApp_SetMacHelpMenuTitleName
1009 #----------------------------------------------------------------------------
1011 class wxPySimpleApp(wxApp
):
1012 def __init__(self
, flag
=0):
1013 wxApp
.__init
__(self
, flag
)
1015 wxInitAllImageHandlers()
1019 class wxPyWidgetTester(wxApp
):
1020 def __init__(self
, size
= (250, 100)):
1022 wxApp
.__init
__(self
, 0)
1025 self
.frame
= wxFrame(None, -1, "Widget Tester", pos
=(0,0), size
=self
.size
)
1026 self
.SetTopWindow(self
.frame
)
1029 def SetWidget(self
, widgetClass
, *args
):
1030 w
= widgetClass(self
.frame
, *args
)
1031 self
.frame
.Show(True)
1033 #----------------------------------------------------------------------------
1034 # DO NOT hold any other references to this object. This is how we
1035 # know when to cleanup system resources that wxWin is holding. When
1036 # the sys module is unloaded, the refcount on sys.__wxPythonCleanup
1037 # goes to zero and it calls the wxApp_CleanUp function.
1039 class __wxPyCleanup
:
1041 self
.cleanup
= wxc
.wxApp_CleanUp
1045 sys
.__wxPythonCleanup
= __wxPyCleanup()
1047 ## # another possible solution, but it gets called too early...
1048 ## if sys.version[0] == '2':
1050 ## atexit.register(wxc.wxApp_CleanUp)
1052 ## sys.exitfunc = wxc.wxApp_CleanUp
1055 #----------------------------------------------------------------------------
1056 #----------------------------------------------------------------------------