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