]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/_extras.py
wxPython documentation updates
[wxWidgets.git] / utils / wxPython / src / _extras.py
CommitLineData
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
9# RCS-ID: $Id$
10# Copyright: (c) 1998 by Total Control Software
11# Licence: wxWindows license
12#----------------------------------------------------------------------------
13
14import sys
15
16#----------------------------------------------------------------------
17# This gives this module's dictionary to the C++ extension code...
18
19_wxSetDictionary(vars())
20
21
22#----------------------------------------------------------------------
23#----------------------------------------------------------------------
24# Helper function to link python methods to wxWindows virtual
25# functions by name.
26
27def _checkForCallback(obj, name, event, theID=-1):
28 try: cb = getattr(obj, name)
29 except: pass
30 else: obj.Connect(theID, -1, event, cb)
31
32def _StdWindowCallbacks(win):
33 _checkForCallback(win, "OnChar", wxEVT_CHAR)
34 _checkForCallback(win, "OnSize", wxEVT_SIZE)
35 _checkForCallback(win, "OnEraseBackground", wxEVT_ERASE_BACKGROUND)
36 _checkForCallback(win, "OnSysColourChanged", wxEVT_SYS_COLOUR_CHANGED)
37 _checkForCallback(win, "OnInitDialog", wxEVT_INIT_DIALOG)
7bf85405 38 _checkForCallback(win, "OnPaint", wxEVT_PAINT)
cf694132
RD
39 _checkForCallback(win, "OnIdle", wxEVT_IDLE)
40
7bf85405
RD
41
42def _StdFrameCallbacks(win):
43 _StdWindowCallbacks(win)
44 _checkForCallback(win, "OnActivate", wxEVT_ACTIVATE)
45 _checkForCallback(win, "OnMenuHighlight", wxEVT_MENU_HIGHLIGHT)
46 _checkForCallback(win, "OnCloseWindow", wxEVT_CLOSE_WINDOW)
47
48
9c039d08
RD
49def _StdDialogCallbacks(win):
50 _StdWindowCallbacks(win)
51 _checkForCallback(win, "OnOk", wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK)
52 _checkForCallback(win, "OnApply", wxEVT_COMMAND_BUTTON_CLICKED, wxID_APPLY)
53 _checkForCallback(win, "OnCancel", wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL)
54 _checkForCallback(win, "OnCloseWindow", wxEVT_CLOSE_WINDOW)
55 _checkForCallback(win, "OnCharHook", wxEVT_CHAR_HOOK)
56
57
cf694132 58def _StdOnScrollCallbacks(win):
7bf85405
RD
59 try: cb = getattr(win, "OnScroll")
60 except: pass
61 else: EVT_SCROLL(win, cb)
62
63
64
65#----------------------------------------------------------------------
66#----------------------------------------------------------------------
67# functions that look and act like the C++ Macros of the same name
68
69
70# Miscellaneous
71def EVT_SIZE(win, func):
72 win.Connect(-1, -1, wxEVT_SIZE, func)
73
74def EVT_MOVE(win, func):
75 win.Connect(-1, -1, wxEVT_MOVE, func)
76
77def EVT_CLOSE(win, func):
78 win.Connect(-1, -1, wxEVT_CLOSE_WINDOW, func)
79
80def EVT_PAINT(win, func):
81 win.Connect(-1, -1, wxEVT_PAINT, func)
82
83def EVT_ERASE_BACKGROUND(win, func):
84 win.Connect(-1, -1, wxEVT_ERASE_BACKGROUND, func)
85
86def EVT_CHAR(win, func):
87 win.Connect(-1, -1, wxEVT_CHAR, func)
88
89def EVT_CHAR_HOOK(win, func):
90 win.Connect(-1, -1, wxEVT_CHAR_HOOK, func)
91
92def EVT_MENU_HIGHLIGHT(win, id, func):
93 win.Connect(id, -1, wxEVT_MENU_HIGHLIGHT, func)
94
95def EVT_MENU_HIGHLIGHT_ALL(win, func):
96 win.Connect(-1, -1, wxEVT_MENU_HIGHLIGHT, func)
97
98def EVT_SET_FOCUS(win, func):
99 win.Connect(-1, -1, wxEVT_SET_FOCUS, func)
100
101def EVT_KILL_FOCUS(win, func):
102 win.Connect(-1, -1, wxEVT_KILL_FOCUS, func)
103
104def EVT_ACTIVATE(win, func):
105 win.Connect(-1, -1, wxEVT_ACTIVATE, func)
106
107def EVT_ACTIVATE_APP(win, func):
108 win.Connect(-1, -1, wxEVT_ACTIVATE_APP, func)
109
110def EVT_END_SESSION(win, func):
111 win.Connect(-1, -1, wxEVT_END_SESSION, func)
112
113def EVT_QUERY_END_SESSION(win, func):
114 win.Connect(-1, -1, wxEVT_QUERY_END_SESSION, func)
115
116def EVT_DROP_FILES(win, func):
117 win.Connect(-1, -1, wxEVT_DROP_FILES, func)
118
119def EVT_INIT_DIALOG(win, func):
120 win.Connect(-1, -1, wxEVT_INIT_DIALOG, func)
121
122def EVT_SYS_COLOUR_CHANGED(win, func):
123 win.Connect(-1, -1, wxEVT_SYS_COLOUR_CHANGED, func)
124
125def EVT_SHOW(win, func):
126 win.Connect(-1, -1, wxEVT_SHOW, func)
127
128def EVT_MAXIMIZE(win, func):
129 win.Connect(-1, -1, wxEVT_MAXIMIZE, func)
130
131def EVT_ICONIZE(win, func):
132 win.Connect(-1, -1, wxEVT_ICONIZE, func)
133
134def EVT_NAVIGATION_KEY(win, func):
135 win.Connect(-1, -1, wxEVT_NAVIGATION_KEY, func)
136
cf694132
RD
137def EVT_IDLE(win, func):
138 win.Connect(-1, -1, wxEVT_IDLE, func)
139
7bf85405
RD
140
141# Mouse Events
142def EVT_LEFT_DOWN(win, func):
143 win.Connect(-1, -1, wxEVT_LEFT_DOWN, func)
144
145def EVT_LEFT_UP(win, func):
146 win.Connect(-1, -1, wxEVT_LEFT_UP, func)
147
148def EVT_MIDDLE_DOWN(win, func):
149 win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func)
150
151def EVT_MIDDLE_UP(win, func):
152 win.Connect(-1, -1, wxEVT_MIDDLE_UP, func)
153
154def EVT_RIGHT_DOWN(win, func):
155 win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func)
156
157def EVT_RIGHT_UP(win, func):
158 win.Connect(-1, -1, wxEVT_RIGHT_UP, func)
159
160def EVT_MOTION(win, func):
161 win.Connect(-1, -1, wxEVT_MOTION, func)
162
163def EVT_LEFT_DCLICK(win, func):
164 win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func)
165
166def EVT_MIDDLE_DCLICK(win, func):
167 win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func)
168
169def EVT_RIGHT_DCLICK(win, func):
170 win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func)
171
172def EVT_LEAVE_WINDOW(win, func):
173 win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func)
174
175def EVT_ENTER_WINDOW(win, func):
176 win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func)
177
178
179# all mouse events
180def EVT_MOUSE_EVENTS(win, func):
181 win.Connect(-1, -1, wxEVT_LEFT_DOWN, func)
182 win.Connect(-1, -1, wxEVT_LEFT_UP, func)
183 win.Connect(-1, -1, wxEVT_MIDDLE_DOWN, func)
184 win.Connect(-1, -1, wxEVT_MIDDLE_UP, func)
185 win.Connect(-1, -1, wxEVT_RIGHT_DOWN, func)
186 win.Connect(-1, -1, wxEVT_RIGHT_UP, func)
187 win.Connect(-1, -1, wxEVT_MOTION, func)
188 win.Connect(-1, -1, wxEVT_LEFT_DCLICK, func)
189 win.Connect(-1, -1, wxEVT_MIDDLE_DCLICK, func)
190 win.Connect(-1, -1, wxEVT_RIGHT_DCLICK, func)
191 win.Connect(-1, -1, wxEVT_LEAVE_WINDOW, func)
192 win.Connect(-1, -1, wxEVT_ENTER_WINDOW, func)
193
194# EVT_COMMAND
195def EVT_COMMAND(win, id, cmd, func):
196 win.Connect(id, -1, cmd, func)
197
198def EVT_COMMAND_RANGE(win, id1, id2, cmd, func):
199 win.Connect(id1, id2, cmd, func)
200
201# Scrolling
202def EVT_SCROLL(win, func):
203 win.Connect(-1, -1, wxEVT_SCROLL_TOP, func)
204 win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func)
205 win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func)
206 win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func)
207 win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func)
208 win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func)
209 win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK,func)
210
211def EVT_SCROLL_TOP(win, func):
212 win.Connect(-1, -1, wxEVT_SCROLL_TOP, func)
213
214def EVT_SCROLL_BOTTOM(win, func):
215 win.Connect(-1, -1, wxEVT_SCROLL_BOTTOM, func)
216
217def EVT_SCROLL_LINEUP(win, func):
218 win.Connect(-1, -1, wxEVT_SCROLL_LINEUP, func)
219
220def EVT_SCROLL_LINEDOWN(win, func):
221 win.Connect(-1, -1, wxEVT_SCROLL_LINEDOWN, func)
222
223def EVT_SCROLL_PAGEUP(win, func):
224 win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func)
225
226def EVT_SCROLL_PAGEDOWN(win, func):
227 win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func)
228
229def EVT_SCROLL_THUMBTRACK(win, func):
230 win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func)
231
232
233
234# Scrolling, with an id
235def EVT_COMMAND_SCROLL(win, id, func):
236 win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
237 win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func)
238 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
239 win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func)
240 win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func)
241 win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func)
242 win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func)
243
244def EVT_COMMAND_SCROLL_TOP(win, id, func):
245 win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
246
247def EVT_COMMAND_SCROLL_BOTTOM(win, id, func):
248 win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func)
249
250def EVT_COMMAND_SCROLL_LINEUP(win, id, func):
251 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
252
253def EVT_COMMAND_SCROLL_LINEDOWN(win, id, func):
254 win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func)
255
256def EVT_COMMAND_SCROLL_PAGEUP(win, id, func):
257 win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func)
258
259def EVT_COMMAND_SCROLL_PAGEDOWN(win, id, func):
260 win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func)
261
262def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func):
263 win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func)
264
265
266# Convenience commands
267def EVT_BUTTON(win, id, func):
268 win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func)
269
270def EVT_CHECKBOX(win, id, func):
271 win.Connect(id, -1, wxEVT_COMMAND_CHECKBOX_CLICKED, func)
272
273def EVT_CHOICE(win, id, func):
274 win.Connect(id, -1, wxEVT_COMMAND_CHOICE_SELECTED, func)
275
276def EVT_LISTBOX(win, id, func):
277 win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_SELECTED, func)
278
279def EVT_LISTBOX_DCLICK(win, id, func):
280 win.Connect(id, -1, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, func)
281
282def EVT_TEXT(win, id, func):
283 win.Connect(id, -1, wxEVT_COMMAND_TEXT_UPDATED, func)
284
285def EVT_TEXT_ENTER(win, id, func):
286 win.Connect(id, -1, wxEVT_COMMAND_TEXT_ENTER, func)
287
288def EVT_MENU(win, id, func):
289 win.Connect(id, -1, wxEVT_COMMAND_MENU_SELECTED, func)
290
291def EVT_MENU_RANGE(win, id1, id2, func):
292 win.Connect(id1, id2, wxEVT_COMMAND_MENU_SELECTED, func)
293
294def EVT_SLIDER(win, id, func):
295 win.Connect(id, -1, wxEVT_COMMAND_SLIDER_UPDATED, func)
296
297def EVT_RADIOBOX(win, id, func):
298 win.Connect(id, -1, wxEVT_COMMAND_RADIOBOX_SELECTED, func)
299
300def EVT_RADIOBUTTON(win, id, func):
301 win.Connect(id, -1, wxEVT_COMMAND_RADIOBUTTON_SELECTED, func)
302
303def EVT_VLBOX(win, id, func):
304 win.Connect(id, -1, wxEVT_COMMAND_VLBOX_SELECTED, func)
305
306def EVT_COMBOBOX(win, id, func):
307 win.Connect(id, -1, wxEVT_COMMAND_COMBOBOX_SELECTED, func)
308
309def EVT_TOOL(win, id, func):
310 win.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED, func)
311
312def EVT_TOOL_RCLICKED(win, id, func):
313 win.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED, func)
314
315def EVT_TOOL_ENTER(win, id, func):
316 win.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER, func)
317
318def EVT_CHECKLISTBOX(win, id, func):
319 win.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, func)
320
321
322# Generic command events
323
324def EVT_COMMAND_LEFT_CLICK(win, id, func):
325 win.Connect(id, -1, wxEVT_COMMAND_LEFT_CLICK, func)
326
327def EVT_COMMAND_LEFT_DCLICK(win, id, func):
328 win.Connect(id, -1, wxEVT_COMMAND_LEFT_DCLICK, func)
329
330def EVT_COMMAND_RIGHT_CLICK(win, id, func):
331 win.Connect(id, -1, wxEVT_COMMAND_RIGHT_CLICK, func)
332
333def EVT_COMMAND_RIGHT_DCLICK(win, id, func):
334 win.Connect(id, -1, wxEVT_COMMAND_RIGHT_DCLICK, func)
335
336def EVT_COMMAND_SET_FOCUS(win, id, func):
337 win.Connect(id, -1, wxEVT_COMMAND_SET_FOCUS, func)
338
339def EVT_COMMAND_KILL_FOCUS(win, id, func):
340 win.Connect(id, -1, wxEVT_COMMAND_KILL_FOCUS, func)
341
342def EVT_COMMAND_ENTER(win, id, func):
343 win.Connect(id, -1, wxEVT_COMMAND_ENTER, func)
344
345
d5c9047a 346# wxNotebook events
7bf85405
RD
347def EVT_NOTEBOOK_PAGE_CHANGED(win, id, func):
348 win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, func)
349
350def EVT_NOTEBOOK_PAGE_CHANGING(win, id, func):
351 win.Connect(id, -1, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, func)
352
353
b639c3c5 354# wxTreeCtrl events
d5c9047a 355def EVT_TREE_BEGIN_DRAG(win, id, func):
4d1d77e8 356 win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_DRAG, func)
d5c9047a
RD
357
358def EVT_TREE_BEGIN_RDRAG(win, id, func):
4d1d77e8 359 win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_RDRAG, func)
d5c9047a
RD
360
361def EVT_TREE_BEGIN_LABEL_EDIT(win, id, func):
4d1d77e8 362 win.Connect(id, -1, wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, func)
d5c9047a
RD
363
364def EVT_TREE_END_LABEL_EDIT(win, id, func):
4d1d77e8 365 win.Connect(id, -1, wxEVT_COMMAND_TREE_END_LABEL_EDIT, func)
d5c9047a
RD
366
367def EVT_TREE_GET_INFO(win, id, func):
4d1d77e8 368 win.Connect(id, -1, wxEVT_COMMAND_TREE_GET_INFO, func)
d5c9047a
RD
369
370def EVT_TREE_SET_INFO(win, id, func):
4d1d77e8 371 win.Connect(id, -1, wxEVT_COMMAND_TREE_SET_INFO, func)
d5c9047a
RD
372
373def EVT_TREE_ITEM_EXPANDED(win, id, func):
4d1d77e8 374 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDED, func)
d5c9047a
RD
375
376def EVT_TREE_ITEM_EXPANDING(win, id, func):
4d1d77e8 377 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_EXPANDING, func)
d5c9047a
RD
378
379def EVT_TREE_ITEM_COLLAPSED(win, id, func):
4d1d77e8 380 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSED, func)
d5c9047a
RD
381
382def EVT_TREE_ITEM_COLLAPSING(win, id, func):
4d1d77e8 383 win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_COLLAPSING, func)
d5c9047a
RD
384
385def EVT_TREE_SEL_CHANGED(win, id, func):
4d1d77e8 386 win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGED, func)
d5c9047a
RD
387
388def EVT_TREE_SEL_CHANGING(win, id, func):
4d1d77e8 389 win.Connect(id, -1, wxEVT_COMMAND_TREE_SEL_CHANGING, func)
d5c9047a
RD
390
391def EVT_TREE_KEY_DOWN(win, id, func):
4d1d77e8 392 win.Connect(id, -1, wxEVT_COMMAND_TREE_KEY_DOWN, func)
d5c9047a
RD
393
394def EVT_TREE_DELETE_ITEM(win, id, func):
4d1d77e8 395 win.Connect(id, -1, wxEVT_COMMAND_TREE_DELETE_ITEM, func)
d5c9047a
RD
396
397
b639c3c5 398# wxSpinButton
62bd0874
RD
399def EVT_SPIN_UP(win, id, func):
400 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
401
402def EVT_SPIN_DOWN(win, id, func):
403 win.Connect(id, -1,wxEVT_SCROLL_LINEDOWN, func)
404
405def EVT_SPIN(win, id, func):
406 win.Connect(id, -1, wxEVT_SCROLL_TOP, func)
407 win.Connect(id, -1, wxEVT_SCROLL_BOTTOM, func)
408 win.Connect(id, -1, wxEVT_SCROLL_LINEUP, func)
409 win.Connect(id, -1, wxEVT_SCROLL_LINEDOWN, func)
410 win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func)
411 win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func)
412 win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func)
413
414
7bf85405 415
b639c3c5
RD
416
417# wxTaskBarIcon
418def EVT_TASKBAR_MOVE(win, func):
419 win.Connect(-1, -1, wxEVT_TASKBAR_MOVE, func)
420
421def EVT_TASKBAR_LEFT_DOWN(win, func):
422 win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DOWN, func)
423
424def EVT_TASKBAR_LEFT_UP(win, func):
425 win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_UP, func)
426
427def EVT_TASKBAR_RIGHT_DOWN(win, func):
428 win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DOWN, func)
429
430def EVT_TASKBAR_RIGHT_UP(win, func):
431 win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_UP, func)
432
433def EVT_TASKBAR_LEFT_DCLICK(win, func):
434 win.Connect(-1, -1, wxEVT_TASKBAR_LEFT_DCLICK, func)
435
436def EVT_TASKBAR_RIGHT_DCLICK(win, func):
437 win.Connect(-1, -1, wxEVT_TASKBAR_RIGHT_DCLICK, func)
438
439
440# wxGrid
441def EVT_GRID_SELECT_CELL(win, fn):
442 win.Connect(-1, -1, wxEVT_GRID_SELECT_CELL, fn)
443
444def EVT_GRID_CREATE_CELL(win, fn):
445 win.Connect(-1, -1, wxEVT_GRID_CREATE_CELL, fn)
446
447def EVT_GRID_CHANGE_LABELS(win, fn):
448 win.Connect(-1, -1, wxEVT_GRID_CHANGE_LABELS, fn)
449
450def EVT_GRID_CHANGE_SEL_LABEL(win, fn):
451 win.Connect(-1, -1, wxEVT_GRID_CHANGE_SEL_LABEL, fn)
452
453def EVT_GRID_CELL_CHANGE(win, fn):
454 win.Connect(-1, -1, wxEVT_GRID_CELL_CHANGE, fn)
455
456def EVT_GRID_CELL_LCLICK(win, fn):
457 win.Connect(-1, -1, wxEVT_GRID_CELL_LCLICK, fn)
458
459def EVT_GRID_CELL_RCLICK(win, fn):
460 win.Connect(-1, -1, wxEVT_GRID_CELL_RCLICK, fn)
461
462def EVT_GRID_LABEL_LCLICK(win, fn):
463 win.Connect(-1, -1, wxEVT_GRID_LABEL_LCLICK, fn)
464
465def EVT_GRID_LABEL_RCLICK(win, fn):
466 win.Connect(-1, -1, wxEVT_GRID_LABEL_RCLICK, fn)
467
468
08127323
RD
469# wxSashWindow
470def EVT_SASH_DRAGGED(win, id, func):
471 win.Connect(id, -1, wxEVT_SASH_DRAGGED, func)
472
473def EVT_SASH_DRAGGED_RANGE(win, id1, id2, func):
474 win.Connect(id1, id2, wxEVT_SASH_DRAGGED, func)
475
476def EVT_QUERY_LAYOUT_INFO(win, func):
477 win.Connect(-1, -1, wxEVT_EVT_QUERY_LAYOUT_INFO, func)
478
479def EVT_CALCULATE_LAYOUT(win, func):
480 win.Connect(-1, -1, wxEVT_EVT_CALCULATE_LAYOUT, func)
481
482
73c5ed36
RD
483# wxListCtrl
484def EVT_LIST_BEGIN_DRAG(win, id, func):
485 win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_DRAG, func)
486
487def EVT_LIST_BEGIN_RDRAG(win, id, func):
488 win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_RDRAG, func)
489
490def EVT_LIST_BEGIN_LABEL_EDIT(win, id, func):
491 win.Connect(id, -1, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, func)
492
493def EVT_LIST_END_LABEL_EDIT(win, id, func):
494 win.Connect(id, -1, wxEVT_COMMAND_LIST_END_LABEL_EDIT, func)
495
496def EVT_LIST_DELETE_ITEM(win, id, func):
497 win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ITEM, func)
498
499def EVT_LIST_DELETE_ALL_ITEMS(win, id, func):
500 win.Connect(id, -1, wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS, func)
501
502def EVT_LIST_GET_INFO(win, id, func):
503 win.Connect(id, -1, wxEVT_COMMAND_LIST_GET_INFO, func)
504
505def EVT_LIST_SET_INFO(win, id, func):
506 win.Connect(id, -1, wxEVT_COMMAND_LIST_SET_INFO, func)
507
508def EVT_LIST_ITEM_SELECTED(win, id, func):
509 win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_SELECTED, func)
510
511def EVT_LIST_ITEM_DESELECTED(win, id, func):
512 win.Connect(id, -1, wxEVT_COMMAND_LIST_ITEM_DESELECTED, func)
513
514def EVT_LIST_KEY_DOWN(win, id, func):
515 win.Connect(id, -1, wxEVT_COMMAND_LIST_KEY_DOWN, func)
516
517def EVT_LIST_INSERT_ITEM(win, id, func):
518 win.Connect(id, -1, wxEVT_COMMAND_LIST_INSERT_ITEM, func)
519
520def EVT_LIST_COL_CLICK(win, id, func):
521 win.Connect(id, -1, wxEVT_COMMAND_LIST_COL_CLICK, func)
b639c3c5
RD
522
523
9c039d08 524#----------------------------------------------------------------------
7bf85405
RD
525
526class wxTimer(wxPyTimer):
527 def __init__(self):
528 wxPyTimer.__init__(self, self.Notify) # derived class must provide
529 # Notify(self) method.
530
531#----------------------------------------------------------------------
532# Some wxWin methods can take "NULL" as parameters, but the shadow classes
533# expect an object with the SWIG pointer as a 'this' member. This class
534# and instance fools the shadow into passing the NULL pointer.
535
536class NullObj:
537 this = 'NULL' # SWIG converts this to (void*)0
538
539NULL = NullObj()
540
541
542#----------------------------------------------------------------------
543# aliases
544
b639c3c5 545wxColor = wxColour
7bf85405
RD
546wxNamedColor = wxNamedColour
547
548wxPyDefaultPosition.Set(-1,-1)
549wxPyDefaultSize.Set(-1,-1)
08127323 550
f2cb3be9
HH
551# aliases so that C++ documentation applies:
552wxDefaultPosition = wxPyDefaultPosition
08127323
RD
553wxDefaultSize = wxPyDefaultSize
554
af309447
RD
555
556# This is to cover up a bug in SWIG. We are redefining
557# the shadow class that is generated for wxAcceleratorTable
558# because SWIG incorrectly uses "arg0.this"
559class wxAcceleratorTable(wxAcceleratorTablePtr):
560 def __init__(self,arg0) :
561 self.this = miscc.new_wxAcceleratorTable(arg0)
562 self.thisown = 1
563
7bf85405
RD
564#----------------------------------------------------------------------
565
cf694132
RD
566## class wxPyStdOutWindow:
567## def __init__(self, title = "wxPython: stdout/stderr"):
568## self.frame = None
569## self.title = title
570
571## def write(self, str):
572## if not self.frame:
573## self.frame = wxFrame(NULL, -1, self.title)
574## self.text = wxTextCtrl(self.frame, -1, "", wxPoint(0,0), wxDefaultSize,
575## wxTE_MULTILINE|wxTE_READONLY)
576## self.frame.SetSize(wxSize(450, 300))
577## self.frame.Show(true)
578## EVT_CLOSE(self.frame, self.OnCloseWindow)
579## self.text.AppendText(str)
7bf85405 580
cf694132
RD
581## def OnCloseWindow(self, event):
582## wxBell()
583## self.frame.Destroy()
584## self.frame = None
585## self.text = None
7bf85405 586
7bf85405 587
cf694132
RD
588## def close(self):
589## if self.frame:
590## self.frame.Close(true)
7bf85405 591
fb5e0af0 592_defRedirect = (wxPlatform == '__WXMSW__')
7bf85405
RD
593
594#----------------------------------------------------------------------
595# The main application class. Derive from this and implement an OnInit
596# method that creates a frame and then calls self.SetTopWindow(frame)
597
598class wxApp(wxPyApp):
599 error = 'wxApp.error'
600
601 def __init__(self, redirect=_defRedirect, filename=None):
602 wxPyApp.__init__(self)
603 self.stdioWin = None
604 self.saveStdio = (sys.stdout, sys.stderr)
605 if redirect:
606 self.RedirectStdio(filename)
607
608 # this initializes wxWindows and then calls our OnInit
609 _wxStart(self.OnInit)
610
611
612 def __del__(self):
613 try:
614 self.RestoreStdio()
615 except:
616 pass
617
618 def RedirectStdio(self, filename):
619 if filename:
620 sys.stdout = sys.stderr = open(filename, 'a')
621 else:
cf694132
RD
622 #raise self.error, 'wxPyStdOutWindow not yet implemented.'
623 self.stdioWin = sys.stdout = sys.stderr = wxPyStdOutWindow()
7bf85405
RD
624
625 def RestoreStdio(self):
626 sys.stdout, sys.stderr = self.saveStdio
627 if self.stdioWin != None:
cf694132 628 self.stdioWin.close()
7bf85405
RD
629
630
631#----------------------------------------------------------------------------
632#
633# $Log$
cf694132
RD
634# Revision 1.12 1999/04/30 03:29:18 RD
635# wxPython 2.0b9, first phase (win32)
636# Added gobs of stuff, see wxPython/README.txt for details
637#
638# Revision 1.11.4.2 1999/03/28 06:35:01 RD
639#
640# wxPython 2.0b8
641# Python thread support
642# various minor additions
643# various minor fixes
644#
645# Revision 1.11.4.1 1999/03/27 23:29:13 RD
646#
647# wxPython 2.0b8
648# Python thread support
649# various minor additions
650# various minor fixes
651#
af309447
RD
652# Revision 1.11 1999/02/20 09:02:55 RD
653# Added wxWindow_FromHWND(hWnd) for wxMSW to construct a wxWindow from a
654# window handle. If you can get the window handle into the python code,
655# it should just work... More news on this later.
656#
657# Added wxImageList, wxToolTip.
658#
659# Re-enabled wxConfig.DeleteAll() since it is reportedly fixed for the
660# wxRegConfig class.
661#
662# As usual, some bug fixes, tweaks, etc.
663#
73c5ed36 664# Revision 1.10 1999/02/01 00:10:39 RD
af309447 665#
73c5ed36
RD
666# Added the missing EVT_LIST_ITEM_SELECTED and friends.
667#
08127323 668# Revision 1.9 1999/01/30 07:30:09 RD
73c5ed36 669#
08127323
RD
670# Added wxSashWindow, wxSashEvent, wxLayoutAlgorithm, etc.
671#
672# Various cleanup, tweaks, minor additions, etc. to maintain
673# compatibility with the current wxWindows.
674#
f2cb3be9
HH
675# Revision 1.8 1999/01/29 21:13:42 HH
676# Added aliases for wxDefaultPosition and wxDefaultSize (from wxPy..) in _extras,
677# so that C++ documentation applies.
678#
b639c3c5 679# Revision 1.7 1998/11/25 08:45:21 RD
f2cb3be9 680#
b639c3c5
RD
681# Added wxPalette, wxRegion, wxRegionIterator, wxTaskbarIcon
682# Added events for wxGrid
683# Other various fixes and additions
684#
62bd0874
RD
685# Revision 1.6 1998/11/16 00:00:52 RD
686# Generic treectrl for wxPython/GTK compiles...
687#
4d1d77e8
RD
688# Revision 1.5 1998/10/20 07:38:02 RD
689# bug fix
690#
d5c9047a
RD
691# Revision 1.4 1998/10/20 06:43:54 RD
692# New wxTreeCtrl wrappers (untested)
693# some changes in helpers
694# etc.
695#
9c039d08 696# Revision 1.3 1998/10/02 06:40:33 RD
d5c9047a 697#
9c039d08
RD
698# Version 0.4 of wxPython for MSW.
699#
fb5e0af0
RD
700# Revision 1.2 1998/08/18 19:48:12 RD
701# more wxGTK compatibility things.
702#
703# It builds now but there are serious runtime problems...
704#
7bf85405
RD
705# Revision 1.1 1998/08/09 08:25:49 RD
706# Initial version
707#
708#
709