]> git.saurik.com Git - wxWidgets.git/blob - wxPython/docs/MigrationGuide.txt
Added a Python port of the OGL library, deprecated the C++ wrapped version.
[wxWidgets.git] / wxPython / docs / MigrationGuide.txt
1 ============================
2 wxPython 2.5 Migration Guide
3 ============================
4
5 This document will help explain some of the major changes in wxPython
6 2.5 since the 2.4 series and let you know what you need to do to adapt
7 your programs to those changes. Be sure to also check in the CHANGES_
8 file like usual to see info about the not so major changes and other
9 things that have been added to wxPython.
10
11 .. _CHANGES: CHANGES.html
12
13
14 wxName Change
15 -------------
16
17 The **wxWindows** project and library is now known as
18 **wxWidgets**. Please see here_ for more details.
19
20 .. _here: http://www.wxwidgets.org/name.htm
21
22 This won't really affect wxPython all that much, other than the fact
23 that the wxwindows.org domain name has changed to wxwidgets.org,
24 so mail list, CVS, and etc. addresses have also changed. We're going
25 to try and smooth the transition as much as possible, but I wanted you
26 all to be aware of this change if you run into any issues.
27
28
29
30 Module Initialization
31 ---------------------
32
33 The import-startup-bootstrap process employed by wxPython was changed
34 such that wxWidgets and the underlying gui toolkit are **not**
35 initialized until the wx.App object is created (but before wx.App.OnInit
36 is called.) This was required because of some changes that were made
37 to the C++ wxApp class.
38
39 There are both benefits and potential problems with this change. The
40 benefits are that you can import wxPython without requiring access to
41 a GUI (for checking version numbers, etc.) and that in a
42 multi-threaded environment the thread that creates the app object will
43 now be the GUI thread instead of the one that imports wxPython. Some
44 potential problems are that the C++ side of the "stock-objects"
45 (wx.BLUE_PEN, wx.TheColourDatabase, etc.) are not initialized until
46 the wx.App object is created, so you should not use them until after
47 you have created your wx.App object. If you do then an exception will
48 be raised telling you that the C++ object has not been initialized
49 yet.
50
51 Also, you will probably not be able to do any kind of GUI or bitmap
52 operation unless you first have created an app object, (even on
53 Windows where most anything was possible before.)
54
55
56
57 SWIG 1.3
58 --------
59
60 wxPython is now using SWIG 1.3.x from CVS (with several of my own
61 customizations added that I hope to get folded back into the main SWIG
62 distribution.) This has some far reaching ramifications:
63
64 All classes derive from object and so all are now "new-style
65 classes." This also allows you to use mixin classes that are
66 new-style and to use properties, staticmethod, etc.
67
68 Public data members of the C++ classes are wrapped as Python
69 properties using property() instead of using
70 __getattr__/__setattr__ hacks like before. Normally you shouldn't
71 notice any difference, but if you were previously doing something
72 with __getattr__/__setattr__ in derived classes then you may have
73 to adjust things.
74
75 Static C++ methods are wrapped using the staticmethod() feature of
76 Python and so are accessible as ClassName.MethodName as expected.
77 They are still also available as top level functions named like
78 ClassName_MethodName as before.
79
80 The relationship between the wxFoo and wxFooPtr classes have
81 changed for the better. Specifically, all instances that you see
82 will be wx.Foo even if they are created internally using wx.FooPtr,
83 because wx.FooPtr.__init__ will change the instance's __class__ as
84 part of the initialization. If you have any code that checks
85 class type using something like isinstance(obj, wx.FooPtr) you will
86 need to change it to isinstance(obj, wx.Foo).
87
88
89
90 Binding Events
91 --------------
92
93 All of the EVT_* functions are now instances of the wx.PyEventBinder
94 class. They have a __call__ method so they can still be used as
95 functions like before, but making them instances adds some
96 flexibility that I expect to take advantave of in the future.
97
98 wx.EvtHandler (the base class for wx.Window) now has a Bind method that
99 makes binding events to windows a little easier. Here is its
100 definition and docstring::
101
102 def Bind(self, event, handler, source=None, id=wxID_ANY, id2=wxID_ANY):
103 """
104 Bind an event to an event handler.
105
106 event One of the EVT_* objects that specifies the
107 type of event to bind.
108
109 handler A callable object to be invoked when the event
110 is delivered to self. Pass None to disconnect an
111 event handler.
112
113 source Sometimes the event originates from a different window
114 than self, but you still want to catch it in self. (For
115 example, a button event delivered to a frame.) By
116 passing the source of the event, the event handling
117 system is able to differentiate between the same event
118 type from different controls.
119
120 id,id2 Used for menu IDs or for event types that require a
121 range of IDs
122
123 """
124
125 Some examples of its use::
126
127 self.Bind(wx.EVT_SIZE, self.OnSize)
128 self.Bind(wx.EVT_BUTTON, self.OnButtonClick, theButton)
129 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
130
131
132 The wx.Menu methods that add items to a wx.Menu have been modified
133 such that they return a reference to the wx.MenuItem that was created.
134 Additionally menu items and toolbar items have been modified to
135 automatically generate a new ID if -1 is given, similar to using -1
136 with window classess. This means that you can create menu or toolbar
137 items and event bindings without having to predefine a unique menu ID,
138 although you still can use IDs just like before if you want. For
139 example, these are all equivallent other than their specific ID
140 values::
141
142 1.
143 item = menu.Append(-1, "E&xit", "Terminate the App")
144 self.Bind(wx.EVT_MENU, self.OnExit, item)
145
146 2.
147 item = menu.Append(wx.ID_EXIT, "E&xit", "Terminate the App")
148 self.Bind(wx.EVT_MENU, self.OnExit, item)
149
150 3.
151 menu.Append(wx.ID_EXIT, "E&xit", "Terminate the App")
152 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
153
154
155 If you create your own custom event types and EVT_* functions, and you
156 want to be able to use them with the Bind method above then you should
157 change your EVT_* to be an instance of wx.PyEventBinder instead of a
158 function. For example, if you used to have something like this::
159
160 myCustomEventType = wxNewEventType()
161 def EVT_MY_CUSTOM_EVENT(win, id, func):
162 win.Connect(id, -1, myCustomEventType, func)
163
164
165 Change it like so::
166
167 myCustomEventType = wx.NewEventType()
168 EVT_MY_CUSTOM_EVENT = wx.PyEventBinder(myCustomEventType, 1)
169
170 The second parameter is an integer in [0, 1, 2] that specifies the
171 number of IDs that are needed to be passed to Connect.
172
173 **[Changed in 2.5.2.0]** There is also an Unbind method added to
174 wx.EvtHandler that can be used to disconenct event handlers. It looks
175 like this::
176
177 def Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY):
178 """
179 Disconencts the event handler binding for event from self.
180 Returns True if successful.
181 """
182
183
184
185
186 The wx Namespace
187 ----------------
188
189 The second phase of the wx Namespace Transition has begun. That means
190 that the real names of the classes and other symbols do not have the
191 'wx' prefix and the modules are located in a Python package named
192 wx. There is still a Python package named wxPython with modules
193 that have the names with the wx prefix for backwards compatibility.
194 Instead of dynamically changing the names at module load time like in
195 2.4, the compatibility modules are generated at build time and contain
196 assignment statements like this::
197
198 wxWindow = wx._core.Window
199
200 Don't let the "_core" in the name bother you. That and some other
201 modules are implementation details, and everything that was in the
202 wxPython.wx module before will still be in the wx package namespace
203 after this change. So from your code you would use it as wx.Window or
204 wxWindow if you import from the wxPython.wx module.
205
206 A few notes about how all of this was accomplished might be
207 interesting... SWIG is now run twice for each module that it is
208 generating code for. The first time it outputs an XML representaion
209 of the parse tree, which can be up to 20MB and 300K lines in size!
210 That XML is then run through a little Python script that creates a
211 file full of SWIG %rename directives that take the wx off of the
212 names, and also generates the Python compatibility file described
213 above that puts the wx back on the names. SWIG is then run a second
214 time to generate the C++ code to implement the extension module, and
215 uses the %rename directives that were generated in the first step.
216
217 Not every name is handled correctly (but the bulk of them are) and so
218 some work has to be done by hand, especially for the reverse-renamers.
219 So expect a few flaws here and there until everything gets sorted out.
220
221 In summary, the wx package and names without the "wx" prefix are now
222 the official form of the wxPython classes. For example::
223
224 import wx
225
226 class MyFrame(wx.Frame):
227 def __init__(self, parent, title):
228 wx.Frame.__init__(self, parent, -1, title)
229 p = wx.Panel(self, -1)
230 b = wx.Button(p, -1, "Do It", (10,10))
231 self.Bind(wx.EVT_BUTTON, self.JustDoIt, b)
232
233 def JustDoIt(self, evt):
234 print "It's done!"
235
236 app = wx.PySimpleApp()
237 f = MyFrame(None, "What's up?")
238 f.Show()
239 app.MainLoop()
240
241 You shouldn't need to migrate all your modules over to use the new
242 package and names right away as there are modules in place that try to
243 provide as much backwards compatibility of the names as possible. If
244 you rewrote the above sample using "from wxPython.wx import * ", the
245 old wxNames, and the old style of event binding it will still work
246 just fine.
247
248
249
250
251 New wx.DC Methods
252 -----------------
253
254 **[Changed in 2.5.2.0]** In wxPython 2.5.1.5 there was a new
255 implementation of the wx.DC Draw and other methods that broke
256 backwards compatibility in the name of consistency. That change has
257 been reverted and the wx.DC Draw methods with 2.4 compatible
258 signatures have been restored. In addition a new set of methods have
259 been added that take wx.Point and/or wx.Size parameters instead of
260 separate integer parameters. The Draw and etc. methods now available
261 in the wx.DC class are::
262
263
264 FloodFill(self, x, y, colour, style = wx.FLOOD_SURFACE)
265 FoodFillPoint(self, pt, colour, style = wx.FLOOD_SURFACE)
266
267 GetPixel(self, x,y)
268 GetPixelPoint(self, pt)
269
270 DrawLine(self, x1, y1, x2, y2)
271 DrawLinePoint(self, pt1, pt2)
272
273 CrossHair(self, x, y)
274 CrossHairPoint(self, pt)
275
276 DrawArc(self, x1, y1, x2, y2, xc, yc)
277 DrawArcPoint(self, pt1, pt2, centre)
278
279 DrawCheckMark(self, x, y, width, height)
280 DrawCheckMarkRect(self, rect)
281
282 DrawEllipticArc(self, x, y, w, h, sa, ea)
283 DrawEllipticArcPointSize(self, pt, sz, sa, ea)
284
285 DrawPoint(self, x, y)
286 DrawPointPoint(self, pt)
287
288 DrawRectangle(self, x, y, width, height)
289 DrawRectangleRect(self, rect)
290 DrawRectanglePointSize(self, pt, sz)
291
292 DrawRoundedRectangle(self, x, y, width, height, radius)
293 DrawRoundedRectangleRect(self, r, radius)
294 DrawRoundedRectanglePointSize(self, pt, sz, radius)
295
296 DrawCircle(self, x, y, radius)
297 DrawCirclePoint(self, pt, radius)
298
299 DrawEllipse(self, x, y, width, height)
300 DrawEllipseRect(self, rect)
301 DrawEllipsePointSize(self, pt, sz)
302
303 DrawIcon(self, icon, x, y)
304 DrawIconPoint(self, icon, pt)
305
306 DrawBitmap(self, bmp, x, y, useMask = False)
307 DrawBitmapPoint(self, bmp, pt, useMask = False)
308
309 DrawText(self, text, x, y)
310 DrawTextPoint(self, text, pt)
311
312 DrawRotatedText(self, text, x, y, angle)
313 DrawRotatedTextPoint(self, text, pt, angle)
314
315 bool Blit(self, xdest, ydest, width, height, sourceDC, xsrc, ysrc,
316 rop = wx.COPY, useMask = False, xsrcMask = -1, ysrcMask = -1)
317 BlitPointSize(self, destPt, sz, sourceDC, srcPt, rop = wx.COPY,
318 useMask = False, srcPtMask = wxDefaultPosition)
319
320
321 SetClippingRegion(self, x, y, width, height)
322 SetClippingRegionPointSize(self, pt, sz)
323 SetClippingRegionAsRegion(self, region)
324 SetClippingRect(self, rect)
325
326
327
328
329
330 Building, Extending and Embedding wxPython
331 ------------------------------------------
332
333 wxPython's setup.py script now expects to use existing libraries for
334 the contribs (gizmos, stc, xrc, etc.) rather than building local
335 copies of them. If you build your own copies of wxPython please be
336 aware that you now need to also build the ogl, stc, xrc, and gizmos
337 libraries in addition to the main wx lib.
338
339 The wxPython.h and other header files are now in
340 .../wxPython/include/wx/wxPython instead of in wxPython/src. You
341 should include it via the "wx/wxPython/wxPython.h" path and add
342 .../wxPython/include to your list of include paths. On OSX and
343 unix-like systems the wxPython headers are installed to the same place
344 that the wxWidgets headers are installed, so if you are building
345 wxPython compatible extensions on those platforms then your include
346 path should already be set properly.
347
348 If you are also using SWIG for your extension then you'll need to
349 adapt how the wxPython .i files are imported into your .i files. See
350 the wxPython sources for examples. Your modules will need to at least
351 ``%import core.i``, and possibly others if you need the definition of
352 other classes. Since you will need them to build your modules using
353 SWIG, the main wxPython .i files are also installed with the wxPython
354 headers in an i_files sibdirectory. It should be enough to pass a
355 -I/pathname on the command line for SWIG to find the files.
356
357 The bulk of wxPython's setup.py has been moved to another module,
358 wx/build/config.py. This module will be installed as part of wxPython
359 so 3rd party modules that wish to use the same setup/configuration
360 code can do so simply by importing this module from their own setup.py
361 scripts using ``import wx.build.config``.
362
363 You no longer need to call wxClassInfo::CleanUpClasses() and
364 wxClassInfo::InitializeClasses() in your extensions or when embedding
365 wxPython.
366
367 The usage of wxPyBeginAllowThreads and wxPyEndAllowThreads has changed
368 slightly. wxPyBeginAllowThreads now returns a boolean value that must
369 be passed to the coresponding wxPyEndAllowThreads function call. This
370 is to help do the RightThing when calls to these two functions are
371 nested, or if calls to external code in other extension modules that
372 are wrapped in the standard Py_(BEGIN|END)_ALLOW_THERADS may result in
373 wx event handlers being called (such as during the call to
374 os.startfile.)
375
376
377
378 Two (or Three!) Phase Create
379 ----------------------------
380
381 If you use the Precreate/Create method of instantiating a window, (for
382 example, to set an extended style flag, or for XRC handlers) then
383 there is now a new method named PostCreate to help with transplanting
384 the brain of the prewindow instance into the derived window instance.
385 For example::
386
387 class MyDialog(wx.Dialog):
388 def __init__(self, parent, ID, title, pos, size, style):
389 pre = wx.PreDialog()
390 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
391 pre.Create(parent, ID, title, pos, size, style)
392 self.PostCreate(pre)
393
394
395
396 Sizers
397 ------
398
399 The hack allowing the old "option" keyword parameter has been removed.
400 If you use keyword args with w.xSizer Add, Insert, or Prepend methods
401 then you will need to use the ``proportion`` name instead of
402 ``option``. (The ``proportion`` keyword was also allowed in 2.4.2.4.)
403
404 When adding a spacer to a sizer you now need to use a wx.Size or a
405 2-integer sequence instead of separate width and height parameters.
406 This was optionally allowed in 2.4, but now it is required. This
407 allows for more consistency in how you add the various types of items
408 to a sizer. The first parameter defines the item (instead of the
409 possibily first two, depending on if you are doing a spacer or not,)
410 and that item can either be a window, a sizer or a spacer (which can
411 be a sequence or a wx.Size.) Removing the option for separate width
412 and height parameters greatly simplified the wrapper code.
413
414 The wx.GridBagSizer class (very similar to the RowColSizer in the
415 library) has been added to C++ and wrapped for wxPython. It can also
416 be used from XRC.
417
418 You should not use AddWindow, AddSizer, AddSpacer (and similar for
419 Insert, Prepend, and etc.) methods any longer. Just use Add and the
420 wrappers will figure out what to do. **[Changed in 2.5.2.0]**
421 AddWindow, AddSize, AddSpacer and etc. will now issue a
422 DeprecationWarning.
423
424 **[Changed in 2.5.2.0]** wx.ADJUST_MINSIZE is now the default
425 behaviour for window items in sizers. This means that the item's
426 GetMinSize and/or GetBestSize will be called when calculating layout
427 and the return value from that will be used for the minimum size used
428 by the sizer. The wx.FIXED_MINSIZE flag was added that will cause the
429 sizer to use the old behaviour in that it will *not* call the window's
430 methods to determine the new best size, instead the minsize that the
431 window had when added to the sizer (or the size the window was created
432 with) will always be used.
433
434 Related to the above, when controls and some other window types are
435 created either the size passed to the constructor, or their "best
436 size" if an explicit size was not passed in, is set as the window's
437 minimal size. For non top-level windows that hasn't meant much in the
438 past, but now the sizers are sensitive to the window's minimal size.
439 The key point to understand here is that it is no longer the window's
440 size it has when added to the sizer that matters, but its minimal
441 size. So you might have some issues to iron out if you create a
442 control without a size and then set its size to something before
443 adding it to the sizer. Since it's minimal size is probably not the
444 size you set then the sizer will appear to be misbehaving. The fix is
445 to either set the size when calling the window's constructor, or to
446 reset the min size by calling SetSizeHints. You can call SetSizeHints
447 at anytime to change the minsize of a window, just call the sizer's
448 Layout method to redistribute the controls as needed.
449
450
451
452 PlatformInfo
453 ------------
454
455 Added wx.PlatformInfo which is a tuple containing strings that
456 describe the platform and build options of wxPython. This lets you
457 know more about the build than just the __WXPORT__ value that
458 wx.Platform contains, such as if it is a GTK2 build. For example,
459 instead of::
460
461 if wx.Platform == "__WXGTK__":
462 ...
463
464 you should do this::
465
466 if "__WXGTK__" in wx.PlatformInfo:
467 ...
468
469 and you can specifically check for a wxGTK2 build by looking for
470 "gtk2" in wx.PlatformInfo. Unicode builds are also detectable this
471 way. If there are any other platform/toolkit/build flags that make
472 sense to add to this tuple please let me know.
473
474 BTW, wx.Platform will probably be deprecated in the future.
475
476
477
478 ActiveX
479 -------
480
481 Lindsay Mathieson's newest wxActiveX_ class has been wrapped into a new
482 extension module called wx.activex. It is very generic and dynamic
483 and should allow hosting of arbitray ActiveX controls within your
484 wxPython apps. So far I've tested it with IE, PDF, and Flash
485 controls, (and there are new samples in the demo and also library
486 modules supporting these.)
487
488 .. _wxActiveX: http://members.optusnet.com.au/~blackpaw1/wxactivex.html
489
490 The new wx.activex module contains a bunch of code, but the most
491 important things to look at are ActiveXWindow and ActiveXEvent.
492 ActiveXWindow derives from wxWindow and the constructor accepts a
493 CLSID for the ActiveX Control that should be created. (There is also
494 a CLSID class that can convert from a progID or a CLSID String.) The
495 ActiveXWindow class simply adds methods that allow you to query some
496 of the TypeInfo exposed by the ActiveX object, and also to get/set
497 properties or call methods by name. The Python implementation
498 automatically handles converting parameters and return values to/from
499 the types expected by the ActiveX code as specified by the TypeInfo,
500 (just bool, integers, floating point, strings and None/Empty so far,
501 but more can be handled later.)
502
503 That's pretty much all there is to the class, as I mentioned before it
504 is very generic and dynamic. Very little is hard-coded and everything
505 that is done with the actual ActiveX control is done at runtime and
506 referenced by property or method name. Since Python is such a dynamic
507 language this is a very good match. I thought for a while about doing
508 some Python black-magic and making the specific methods/properties of
509 the actual ActiveX control "appear" at runtime, but then decided that
510 it would be better and more understandable to do it via subclassing.
511 So there is a utility class in wx.activex that given an existing
512 ActiveXWindow instance can generate a .py module containing a derived
513 class with real methods and properties that do the Right Thing to
514 reflect those calls to the real ActiveX control. There is also a
515 script/tool module named genaxmodule that given a CLSID or progID and
516 a class name, will generate the module for you. There are a few
517 examples of the output of this tool in the wx.lib package, see
518 iewin.py, pdfwin.py and flashwin.py.
519
520 Currently the genaxmodule tool will tweak some of the names it
521 generates, but this can be controled if you would like to do it
522 differently by deriving your own class from GernerateAXModule,
523 overriding some methods and then using this class from a tool like
524 genaxmodule. [TODO: make specifying a new class on genaxmodule's
525 command-line possible.] The current default behavior is that any
526 event names that start with "On" will have the "On" dropped, property
527 names are converted to all lower case, and if any name is a Python
528 keyword it will have an underscore appended to it. GernerateAXModule
529 does it's best when generating the code in the new module, but it can
530 only be as good as the TypeInfo data available from the ActiveX
531 control so sometimes some tweaking will be needed. For example, the
532 IE web browser control defines the Flags parameter of the Navigate2
533 method as required, but MSDN says it is optional.
534
535 It is intended that this new wx.activex module will replace both the
536 older version of Lindsay's code available in iewin.IEHtmlWindow, and
537 also the wx.lib.activexwraper module. Probably the biggest
538 differences you'll ecounter in migrating activexwrapper-based code
539 (besides events working better without causing deadlocks) is that
540 events are no longer caught by overriding methods in your derived
541 class. Instead ActiveXWindow uses the wx event system and you bind
542 handlers for the ActiveX events exactly the same way you do for any wx
543 event. There is just one extra step needed and that is creating an
544 event ID from the ActiveX event name, and if you use the genaxmodule
545 tool then this extra step will be handled for you there. For example,
546 for the StatusTextChange event in the IE web browser control, this
547 code is generated for you::
548
549 wxEVT_StatusTextChange = wx.activex.RegisterActiveXEvent('StatusTextChange')
550 EVT_StatusTextChange = wx.PyEventBinder(wxEVT_StatusTextChange, 1)
551
552 and you would use it in your code like this::
553
554 self.Bind(iewin.EVT_StatusTextChange, self.UpdateStatusText, self.ie)
555
556 When the event happens and your event handler function is called the
557 event properties from the ActiveX control (if any) are converted to
558 attributes of the event object passed to the handler. (Can you say
559 'event' any more times in a single sentence? ;-) ) For example the
560 StatusTextChange event will also send the text that should be put into
561 the status line as an event parameter named "Text" and you can access
562 it your handlers as an attribute of the event object like this::
563
564 def UpdateStatusText(self, evt):
565 self.SetStatusText(evt.Text)
566
567 Usually these event object attributes should be considered read-only,
568 but some will be defined by the TypeInfo as output parameters. In
569 those cases if you modify the event object's attribute then that value
570 will be returned to the ActiveX control. For example, to prevent a
571 new window from being opened by the IE web browser control you can do
572 this in the handler for the iewin.EVT_NewWindow2 event::
573
574 def OnNewWindow2(self, evt):
575 evt.Cancel = True
576
577 So how do you know what methods, events and properties that an ActiveX
578 control supports? There is a funciton in wx.activex named GetAXInfo
579 that returns a printable summary of the TypeInfo from the ActiveX
580 instance passed in. You can use this as an example of how to browse
581 the TypeInfo provided, and there is also a copy of this function's
582 output appended as a comment to the modules produced by the
583 genaxmodule tool. Beyond that you'll need to consult the docs
584 provided by the makers of the ActiveX control that you are using.
585
586
587
588 OGL is dead! LONG LIVE OGL!
589 ---------------------------
590
591 The wx.ogl module has been deprecated in favor of the new Python port
592 of the OGL library located at wx.lib.ogl contributed by Pierre Hjälm.
593 This will hopefully greatly extend the life of OGL within wxPython by
594 making it more easily maintainable and less prone to getting rusty as
595 there seems to be less and less interest in maintaining the C++
596 version.
597
598 There are only a few known compatibility issues at this time. First
599 is the location of OGL. The deprecated version is located in the
600 wx.ogl module, and the new version is in the wx.lib.ogl package. So
601 this just means that to start using the new version you need to adjust
602 your imports. So if your code currently has something like this::
603
604 import wx
605 import wx.ogl as ogl
606
607 Then just change it to this::
608
609 import wx
610 import wx.lib.ogl as ogl
611
612
613
614
615
616 Obsolete Modules
617 ----------------
618
619 Instead of over a dozen separate extension modules linked together
620 into a single extension module, the "core" module is now just a few
621 extensions that are linked independently, and then merged together
622 later into the main namespace via Python code.
623
624 Because of the above and also because of the way the new SWIG works,
625 the "internal" module names have changed, but you shouldn't have been
626 using them anyway so it shouldn't bother you. ;-) In case you were
627 erroneously using them in 2.4, here are the internal extension modules
628 no longer exist:
629
630 * clip_dnd
631 * cmndlgs
632 * controls
633 * controls2
634 * events
635 * filesys
636 * fonts
637 * frames
638 * gdi
639 * image
640 * mdi
641 * misc
642 * misc2
643 * printfw
644 * sizers
645 * stattool
646 * streams
647 * utils
648 * windows
649 * windows2
650 * windows3
651
652 They have been replaced by the following, but please remember that
653 these are just "implementation details" and you should really be using
654 the objects in these modules only via the wx or wxPython.wx packages:
655
656 * _core
657 * _gdi
658 * _windows
659 * _controls
660 * _misc
661
662
663 The help module no longer exists and the classes therein are now part
664 of the core module imported with wxPython.wx or the wx package.
665
666
667
668
669 Other Stuff
670 -----------
671
672 wxPyDefaultPosition and wxPyDefaultSize are gone. Use the
673 wxDefaultPosition and wxDefaultSize objects instead.
674
675 Similarly, the wxSystemSettings backwards compatibiility aliases for
676 GetSystemColour, GetSystemFont and GetSystemMetric have also gone into
677 the bit-bucket. Use GetColour, GetFont and GetMetric instead.
678
679 Use the Python True/False constants instead of the true, TRUE, false,
680 FALSE that used to be provided with wxPython.
681
682 Use None instead of the ancient and should have been removed a long
683 time ago wx.NULL alias.
684
685 wx.TreeCtrl.GetFirstChild no longer needs to be passed the cookie
686 variable as the 2nd parameter. It still returns it though, for use
687 with GetNextChild.
688
689 The wx.NO_FULL_REPAINT_ON_RESIZE style is now the default style for
690 all windows. The name still exists for compatibility, but it is set
691 to zero. If you want to disable the setting (so it matches the old
692 default) then you need to use the new wx.FULL_REPAINT_ON_RESIZE style
693 flag otherwise only the freshly exposed areas of the window will be
694 refreshed.
695
696 wxPyTypeCast has been removed. Since we've had the OOR (Original
697 Object Return) for a couple years now there should be no need to use
698 wxPyTypeCast at all.
699
700 If you use the old wxPython package and wxPython.wx namespace then
701 there are compatibility aliases for much of the above items.
702
703 The wxWave class has been renamed to wxSound, and now has a slightly
704 different API.
705
706 wx.TaskbarIcon works on wxGTK-based platforms (for some window
707 managers,) however you have to manage it a little bit more than you
708 did before. Basically, the app will treat it like a top-level frame
709 in that if the wx.TaskBarIcon still exists when all the frames are
710 closed then the app will still not exit. You need to ensure that the
711 wx.TaskBarIcon is destroyed when your last Frame is closed. For
712 wxPython apps it is usually enough if your main frame object holds the
713 only reference to the wx.TaskBarIcon, then when the frame is closed
714 Python reference counting takes care of the rest.
715
716 Before Python 2.3 it was possible to pass a floating point object as a
717 parameter to a function that expected an integer, and the
718 PyArg_ParseTuple family of functions would automatically convert to
719 integer by truncating the fractional portion of the number. With
720 Python 2.3 that behavior was deprecated and a deprecation warning is
721 raised when you pass a floating point value, (for example, calling
722 wx.DC.DrawLine with floats for the position and size,) and lots of
723 developers using wxPython had to scramble to change their code to call
724 int() before calling wxPython methods. Recent changes in SWIG have
725 moved the conversion out of PyArg_ParseTuple to custom code that SWIG
726 generates. Since the default conversion fragment was a little too
727 strict and didn't generate a very meaningful exception when it failed,
728 I decided to use a custom fragment instead, and it turned out that
729 it's very easy to allow floats to be converted again just like they
730 used to be. So, in a nutshell, any numeric type that can be
731 converted to an integer is now legal to be passed to SWIG wrapped
732 functions in wxPython for parameters that are expecting an integer.
733 If the object is not already an integer then it will be asked to
734 convert itself to one. A similar conversion fragment is in place for
735 parameters that expect floating point values.
736
737 **[Changed in 2.5.2.0]** The MaskedEditCtrl modules have been moved
738 to their own sub-package, wx.lib.masked. See the docstrings and demo
739 for changes in capabilities, usage, etc.
740
741 **[Changed in 2.5.2.0]** wx.MaskColour constructor has been deprecated
742 and will raise a DeprecationWarning if used. The main wx.Mask
743 constructor has been modified to be compatible with wx.MaskColour so
744 you should use it instead.