]> git.saurik.com Git - wxWidgets.git/blame - wxPython/docs/MigrationGuide.txt
reSWIGged
[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
65 classes"
66
67 Public data members of the C++ classes are wrapped as Python
68 properties using property() instead of using __getattr__/__setattr__
69 like before. Normally you shouldn't notice any difference, but if
70 you were previously doing something with __getattr__/__setattr__
71 in derived classes then you may have to adjust things.
72
73 Static C++ methods are wrapped using the staticmethod()
74 feature of Python and so are accessible as ClassName.MethodName
75 as expected. They are still available as top level functions
76 ClassName_MethodName as before.
77
78 The relationship between the wxFoo and wxFooPtr classes have
79 changed for the better. Specifically, all instances that you see
80 will be wxFoo even if they are created internally using wxFooPtr,
81 because wxFooPtr.__init__ will change the instance's __class__ as
82 part of the initialization. If you have any code that checks
83 class type using something like isinstance(obj, wxFooPtr) you will
84 need to change it to isinstance(obj, wxFoo).
85
86
87
88Binding Events
89--------------
90
91All of the EVT_* functions are now instances of the wx.PyEventBinder
92class. They have a __call__ method so they can still be used as
93functions like before, but making them instances adds some
29bfe46b 94flexibility that I expect to take advantave of in the future.
d14a1e28
RD
95
96wx.EvtHandler (the base class for wx.Window) now has a Bind method that
97makes binding events to windows a little easier. Here is its
98definition and docstring::
99
100 def Bind(self, event, handler, source=None, id=wxID_ANY, id2=wxID_ANY):
101 """
102 Bind an event to an event handler.
103
104 event One of the EVT_* objects that specifies the
105 type of event to bind.
106
107 handler A callable object to be invoked when the event
108 is delivered to self. Pass None to disconnect an
109 event handler.
110
111 source Sometimes the event originates from a different window
112 than self, but you still want to catch it in self. (For
113 example, a button event delivered to a frame.) By
114 passing the source of the event, the event handling
115 system is able to differentiate between the same event
116 type from different controls.
117
118 id,id2 Used for menu IDs or for event types that require a
119 range of IDs
120
121 """
122
123Some examples of its use::
124
125 self.Bind(wx.EVT_SIZE, self.OnSize)
126 self.Bind(wx.EVT_BUTTON, self.OnButtonClick, theButton)
c8000995
RD
127 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
128
129
130The wx.Menu methods that add items to a wx.Menu have been modified
131such that they return a reference to the wx.MenuItem that was created.
132Additionally menu items and toolbar items have been modified to
133automatically generate a new ID if -1 is given, similar to using -1
134with window classess. This means that you can create menu or toolbar
135items and event bindings without having to predefine a unique menu ID,
136although you still can use IDs just like before if you want. For
e8a71fa0
RD
137example, these are all equivallent other than their specific ID
138values::
c8000995
RD
139
140 1.
141 item = menu.Append(-1, "E&xit", "Terminate the App")
142 self.Bind(wx.EVT_MENU, self.OnExit, item)
143
144 2.
145 item = menu.Append(wx.ID_EXIT, "E&xit", "Terminate the App")
146 self.Bind(wx.EVT_MENU, self.OnExit, item)
d14a1e28 147
c8000995
RD
148 3.
149 menu.Append(wx.ID_EXIT, "E&xit", "Terminate the App")
150 self.Bind(wx.EVT_MENU, self.OnExit, id=wx.ID_EXIT)
151
152
d14a1e28
RD
153If you create your own custom event types and EVT_* functions, and you
154want to be able to use them with the Bind method above then you should
155change your EVT_* to be an instance of wxPyEventBinder instead of a
29bfe46b 156function. For example, if you used to have something like this::
d14a1e28
RD
157
158 myCustomEventType = wxNewEventType()
159 def EVT_MY_CUSTOM_EVENT(win, id, func):
160 win.Connect(id, -1, myCustomEventType, func)
161
162
163Change it like so::
164
6158f936
RD
165 myCustomEventType = wx.NewEventType()
166 EVT_MY_CUSTOM_EVENT = wx.PyEventBinder(myCustomEventType, 1)
d14a1e28
RD
167
168The second parameter is an integer in [0, 1, 2] that specifies the
169number of IDs that are needed to be passed to Connect.
170
171
172
c8000995
RD
173
174
d14a1e28
RD
175The wx Namespace
176----------------
177
178The second phase of the wx Namespace Transition has begun. That means
179that the real names of the classes and other symbols do not have the
180'wx' prefix and the modules are located in a Python package named
181wx. There is still a Python package named wxPython with modules
182that have the names with the wx prefix for backwards compatibility.
183Instead of dynamically changing the names at module load time like in
1842.4, the compatibility modules are generated at build time and contain
185assignment statements like this::
186
187 wxWindow = wx.core.Window
188
189Don't let the "core" in the name bother you. That and some other
190modules are implementation details, and everything that was in the
191wxPython.wx module before will still be in the wx package namespace
192after this change. So from your code you would use it as wx.Window.
193
194A few notes about how all of this was accomplished might be
195interesting... SWIG is now run twice for each module that it is
196generating code for. The first time it outputs an XML representaion
197of the parse tree, which can be up to 20MB and 300K lines in size!
198That XML is then run through a little Python script that creates a
199file full of SWIG %rename directives that take the wx off of the
200names, and also generates the Python compatibility file described
201above that puts the wx back on the names. SWIG is then run a second
202time to generate the C++ code to implement the extension module, and
203uses the %rename directives that were generated in the first step.
204
205Not every name is handled correctly (but the bulk of them are) and so
206some work has to be done by hand, especially for the reverse-renamers.
207So expect a few flaws here and there until everything gets sorted out.
208
209In summary, the wx package and names without the "wx" prefix are now
210the official form of the wxPython classes. For example::
211
212 import wx
213
214 class MyFrame(wx.Frame):
215 def __init__(self, parent, title):
216 wx.Frame.__init__(self, parent, -1, title)
217 p = wx.Panel(self, -1)
218 b = wx.Button(p, -1, "Do It", (10,10))
219 self.Bind(wx.EVT_BUTTON, self.JustDoIt, b)
220
221 def JustDoIt(self, evt):
222 print "It's done!"
223
224 app = wx.PySimpleApp()
225 f = MyFrame(None, "What's up?")
226 f.Show()
227 app.MainLoop()
228
229You shouldn't need to migrate all your modules over to use the new
230package and names right away as there are modules in place that try to
231provide as much backwards compatibility of the names as possible. If
82a074ce 232you rewrote the above sample using "from wxPython.wx import * ", the
d14a1e28
RD
233old wxNames, and the old style of event binding it will still work
234just fine.
235
236
237
238
239New wx.DC Methods
240-----------------
241
242Many of the Draw methods of wx.DC have alternate forms in C++ that take
243wxPoint or wxSize parameters (let's call these *Type A*) instead of
244the individual x, y, width, height, etc. parameters (and we'll call
245these *Type B*). In the rest of the library I normally made the *Type
246A* forms of the methods be the default method with the "normal" name,
247and had renamed the *Type B* forms of the methods to some similar
248name. For example in wx.Window we have these Python methods::
249
250 SetSize(size) # Type A
251 SetSizeWH(width, height) # Type B
252
253
254For various reasons the new *Type A* methods in wx.DC were never added
255and the existing *Type B* methods were never renamed. Now that lots
256of other things are also changing in wxPython it has been decided that
257it is a good time to also do the method renaming in wx.DC too in order
258to be consistent with the rest of the library. The methods in wx.DC
259that are affected are listed here::
260
261 FloodFillXY(x, y, colour, style = wx.FLOOD_SURFACE)
262 FloodFill(point, colour, style = wx.FLOOD_SURFACE)
263
264 GetPixelXY(x, y)
265 GetPixel(point)
266
267 DrawLineXY(x1, y1, x2, y2)
268 DrawLine(point1, point2)
269
270 CrossHairXY(x, y)
271 CrossHair(point)
272
273 DrawArcXY(x1, y1, x2, y2, xc, yc)
274 DrawArc(point1, point2, center)
275
276 DrawCheckMarkXY(x, y, width, height)
277 DrawCheckMark(rect)
278
279 DrawEllipticArcXY(x, y, w, h, start_angle, end_angle)
280 DrawEllipticArc(point, size, start_angle, end_angle)
281
282 DrawPointXY(x, y)
283 DrawPoint(point)
284
285 DrawRectangleXY(x, y, width, height)
286 DrawRectangle(point, size)
287 DrawRectangleRect(rect)
288
289 DrawRoundedRectangleXY(x, y, width, height, radius)
290 DrawRoundedRectangle(point, size, radius)
291 DrawRoundedRectangleRect(rect, radius)
292
293 DrawCircleXY(x, y, radius)
294 DrawCircle(point, radius)
295
296 DrawEllipseXY(x, y, width, height)
297 DrawEllipse(point, size)
298 DrawEllipseRect(rect)
299
300 DrawIconXY(icon, x, y)
301 DrawIcon(icon, point)
302
303 DrawBitmapXY(bmp, x, y, useMask = FALSE)
304 DrawBitmap(bmp, point, useMask = FALSE)
305
306 DrawTextXY(text, x, y)
307 DrawText(text, point)
308
309 DrawRotatedTextXY(text, x, y, angle)
310 DrawRotatedText(text, point, angle)
311
312
313 BlitXY(xdest, ydest, width, height, sourceDC, xsrc, ysrc,
314 rop = wxCOPY, useMask = FALSE, xsrcMask = -1, ysrcMask = -1)
315 Blit(destPt, size, sourceDC, srcPt,
316 rop = wxCOPY, useMask = FALSE, srcPtMask = wx.DefaultPosition)
317
82a074ce 318 SetClippingRegionXY(x, y, width, height)
4da6d35e
RD
319 SetClippingRegion(point, size)
320 SetClippingRect(rect)
321 SetClippingRegionAsRegion(region);
322
d14a1e28 323
4942342c
RD
324If you have code that draws on a DC and you are using the new wx
325namespace then you **will** get errors because of these changes, but
326it should be easy to fix the code. You can either change the name of
327the *Type B* method called to the names shown above, or just add
328parentheses around the parameters as needed to turn them into tuples
329and let the SWIG typemaps turn them into the wx.Point or wx.Size
330object that is expected. Then you will be calling the new *Type A*
331method. For example, if you had this code before::
d14a1e28
RD
332
333 dc.DrawRectangle(x, y, width, height)
334
9ec83f8d
RD
335You could either continue to use the *Type B* method by changing the
336name to DrawRectangleXY, or just change it to the new *Type A* by
d14a1e28
RD
337adding some parentheses like this::
338
339 dc.DrawRectangle((x, y), (width, height))
340
9ec83f8d 341Or if you were already using a point and size like this::
d14a1e28
RD
342
343 dc.DrawRectangle(p.x, p.y, s.width, s.height)
344
345Then you can just simplify it like this::
346
347 dc.DrawRectangle(p, s)
348
4942342c 349Now before you start yelling and screaming at me for breaking all your
95fed4d8
RD
350code, take note that up above I said, "...using the new wx
351namespace..." That's because if you are still importing from
352wxPython.wx then there are some classes defined there with Draw and
353etc. methods that have 2.4 compatible signatures. Unfortunately there
354is one exception to this behaviour. If a DC is returned from a
355function or method then an instance of the new class (with the new
356methods described above) will be returned instead of the compatibility
357class. If/When the old wxPython.wx namespace is removed then these
358compatibility classes will be removed too so you should plan on
359migrating to the new namespace and new DC Draw methods before that
360time.
d14a1e28
RD
361
362
363
364Building, Extending and Embedding wxPython
365------------------------------------------
366
367wxPython's setup.py script now expects to use existing libraries for
368the contribs (gizmos, stc, xrc, etc.) rather than building local
369copies of them. If you build your own copies of wxPython please be
370aware that you now need to also build the ogl, stc, xrc, and gizmos
29bfe46b 371libraries in addition to the main wx lib.
d14a1e28
RD
372
373The wxPython.h and other header files are now in
9ec83f8d
RD
374.../wxPython/include/wx/wxPython instead of in wxPython/src. You
375should include it via the "wx/wxPython/wxPython.h" path and add
29bfe46b
RD
376.../wxPython/include to your list of include paths. On OSX and
377unix-like systems the wxPython headers are installed to the same place
9ec83f8d
RD
378that the wxWidgets headers are installed, so if you are building
379wxPython compatible extensions on those platforms then your include
380path should already be set properly.
29bfe46b
RD
381
382If you are also using SWIG for your extension then you'll need to
383adapt how the wxPython .i files are imported into your .i files. See
384the wxPython sources for examples. Your modules will need to at least
385``%import core.i``, and possibly others if you need the definition of
9ec83f8d
RD
386other classes. Since you will need them to build your modules using
387SWIG, the main wxPython .i files are also installed with the wxPython
388headers in an i_files sibdirectory. It should be enough to pass a
389-I/pathname on the command line for SWIG to find the files.
29bfe46b
RD
390
391The bulk of wxPython's setup.py has been moved to another module,
392wx/build/config.py. This module will be installed as part of wxPython
393so 3rd party modules that wish to use the same setup/configuration
394code can do so simply by importing this module from their own setup.py
395scripts using ``import wx.build.config``.
d14a1e28
RD
396
397You no longer need to call wxClassInfo::CleanUpClasses() and
398wxClassInfo::InitializeClasses() in your extensions or when embedding
399wxPython.
400
29bfe46b
RD
401The usage of wxPyBeginAllowThreads and wxPyEndAllowThreads has changed
402slightly. wxPyBeginAllowThreads now returns a boolean value that must
403be passed to the coresponding wxPyEndAllowThreads function call. This
404is to help do the RightThing when calls to these two functions are
405nested, or if calls to external code in other extension modules that
406are wrapped in the standard Py_(BEGIN|END)_ALLOW_THERADS may result in
407wx event handlers being called (such as during the call to
408os.startfile.)
d14a1e28
RD
409
410
411
412Two (or Three!) Phase Create
413----------------------------
414
415If you use the Precreate/Create method of instantiating a window, (for
416example, to set an extended style flag, or for XRC handlers) then
417there is now a new method named PostCreate to help with transplanting
418the brain of the prewindow instance into the derived window instance.
419For example::
420
421 class MyDialog(wx.Dialog):
422 def __init__(self, parent, ID, title, pos, size, style):
423 pre = wx.PreDialog()
424 pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
425 pre.Create(parent, ID, title, pos, size, style)
426 self.PostCreate(pre)
427
428
429
430Sizers
431------
432
e6a5dac6 433The hack allowing the old "option" keyword parameter has been removed.
9ec83f8d 434If you use keyword args with w.xSizer Add, Insert, or Prepend methods
29bfe46b 435then you will need to use the ``proportion`` name instead of ``option``.
d14a1e28 436
29bfe46b 437When adding a spacer to a sizer you now need to use a wx.Size or a
d14a1e28 4382-integer sequence instead of separate width and height parameters.
95fed4d8
RD
439This allows for more consistency in how you add the various types of
440items to a sizer. The first parameter defines the item (instead of
441the possibily first two, depending on if you are doing a spacer or
442not,) and that item can either be a window, a sizer or a spacer (which
443can be a sequence or a wx.Size.)
d14a1e28 444
29bfe46b 445The wx.GridBagSizer class (very similar to the RowColSizer in the
d14a1e28
RD
446library) has been added to C++ and wrapped for wxPython. It can also
447be used from XRC.
448
449You should not use AddWindow, AddSizer, AddSpacer (and similar for
450Insert, Prepend, and etc.) methods any longer. Just use Add and the
451wrappers will figure out what to do.
452
95fed4d8
RD
453**[Changed in 2.5.1.6]** wx.ADJUST_MINSIZE is now the default
454behaviour for window items in sizers. This means that the item's
455GetAdjustedBestSize will be called when calculating layout and the
456return value from that will be used for the minimum size. Added
761b244f 457wx.FIXED_MINSIZE flag for when you would like the old behavior but you
95fed4d8 458should only need it when your desired size is smaller than the item's
1980f3fa
RD
459GetBestSize. When a window is added to a sizer it's initial size, if
460any, is set as the window's minimal size using SetSizeHints if there
461isn't already a minimal size.
95fed4d8 462
d14a1e28 463
dd346b94
RD
464PlatformInfo
465------------
466
467Added wx.PlatformInfo which is a tuple containing strings that
468describe the platform and build options of wxPython. This lets you
469know more about the build than just the __WXPORT__ value that
470wx.Platform contains, such as if it is a GTK2 build. For example,
471instead of::
472
473 if wx.Platform == "__WXGTK__":
474 ...
475
476you should do this::
477
478 if "__WXGTK__" in wx.PlatformInfo:
479 ...
480
481and you can specifically check for a wxGTK2 build by looking for
482"gtk2" in wx.PlatformInfo. Unicode builds are also detectable this
483way. If there are any other platform/toolkit/build flags that make
484sense to add to this tuple please let me know.
485
486BTW, wx.Platform will probably be deprecated in the future.
487
488
d14a1e28 489
b7c75283
RD
490ActiveX
491-------
492
493Lindsay Mathieson's newest wxActiveX_ class has been wrapped into a new
494extension module called wx.activex. It is very generic and dynamic
495and should allow hosting of arbitray ActiveX controls within your
496wxPython apps. So far I've tested it with IE, PDF, and Flash
497controls, (and there are new samples in the demo and also library
498modules supporting these.)
499
500.. _wxActiveX: http://members.optusnet.com.au/~blackpaw1/wxactivex.html
501
502The new wx.activex module contains a bunch of code, but the most
503important things to look at are ActiveXWindow and ActiveXEvent.
504ActiveXWindow derives from wxWindow and the constructor accepts a
505CLSID for the ActiveX Control that should be created. (There is also
506a CLSID class that can convert from a progID or a CLSID String.) The
507ActiveXWindow class simply adds methods that allow you to query some
508of the TypeInfo exposed by the ActiveX object, and also to get/set
509properties or call methods by name. The Python implementation
510automatically handles converting parameters and return values to/from
511the types expected by the ActiveX code as specified by the TypeInfo,
512(just bool, integers, floating point, strings and None/Empty so far,
513but more can be handled later.)
514
515That's pretty much all there is to the class, as I mentioned before it
516is very generic and dynamic. Very little is hard-coded and everything
517that is done with the actual ActiveX control is done at runtime and
518referenced by property or method name. Since Python is such a dynamic
519language this is a very good match. I thought for a while about doing
520some Python black-magic and making the specific methods/properties of
521the actual ActiveX control "appear" at runtime, but then decided that
522it would be better and more understandable to do it via subclassing.
523So there is a utility class in wx.activex that given an existing
524ActiveXWindow instance can generate a .py module containing a derived
525class with real methods and properties that do the Right Thing to
526reflect those calls to the real ActiveX control. There is also a
527script/tool module named genaxmodule that given a CLSID or progID and
528a class name, will generate the module for you. There are a few
b098694c 529examples of the output of this tool in the wx.lib package, see
b7c75283
RD
530iewin.py, pdfwin.py and flashwin.py.
531
532Currently the genaxmodule tool will tweak some of the names it
533generates, but this can be controled if you would like to do it
534differently by deriving your own class from GernerateAXModule,
535overriding some methods and then using this class from a tool like
536genaxmodule. [TODO: make specifying a new class on genaxmodule's
537command-line possible.] The current default behavior is that any
538event names that start with "On" will have the "On" dropped, property
539names are converted to all lower case, and if any name is a Python
540keyword it will have an underscore appended to it. GernerateAXModule
541does it's best when generating the code in the new module, but it can
542only be as good as the TypeInfo data available from the ActiveX
543control so sometimes some tweaking will be needed. For example, the
544IE web browser control defines the Flags parameter of the Navigate2
545method as required, but MSDN says it is optional.
546
547It is intended that this new wx.activex module will replace both the
548older version of Lindsay's code available in iewin.IEHtmlWindow, and
549also the wx.lib.activexwraper module. Probably the biggest
b098694c 550differences you'll ecounter in migrating activexwrapper-based code
b7c75283
RD
551(besides events working better without causing deadlocks) is that
552events are no longer caught by overriding methods in your derived
553class. Instead ActiveXWindow uses the wx event system and you bind
554handlers for the ActiveX events exactly the same way you do for any wx
555event. There is just one extra step needed and that is creating an
556event ID from the ActiveX event name, and if you use the genaxmodule
557tool then this extra step will be handled for you there. For example,
558for the StatusTextChange event in the IE web browser control, this
559code is generated for you::
560
561 wxEVT_StatusTextChange = wx.activex.RegisterActiveXEvent('StatusTextChange')
562 EVT_StatusTextChange = wx.PyEventBinder(wxEVT_StatusTextChange, 1)
563
564and you would use it in your code like this::
565
566 self.Bind(iewin.EVT_StatusTextChange, self.UpdateStatusText, self.ie)
567
568When the event happens and your event handler function is called the
569event properties from the ActiveX control (if any) are converted to
570attributes of the event object passed to the handler. (Can you say
571'event' any more times in a single sentence? ;-) ) For example the
572StatusTextChange event will also send the text that should be put into
573the status line as an event parameter named "Text" and you can access
b098694c 574it your handlers as an attribute of the event object like this::
b7c75283
RD
575
576 def UpdateStatusText(self, evt):
577 self.SetStatusText(evt.Text)
578
b098694c
RD
579Usually these event object attributes should be considered read-only,
580but some will be defined by the TypeInfo as output parameters. In
581those cases if you modify the event object's attribute then that value
582will be returned to the ActiveX control. For example, to prevent a
583new window from being opened by the IE web browser control you can do
584this in the handler for the iewin.EVT_NewWindow2 event::
585
586 def OnNewWindow2(self, evt):
587 evt.Cancel = True
b7c75283 588
29bfe46b 589So how do you know what methods, events and properties that an ActiveX
b7c75283
RD
590control supports? There is a funciton in wx.activex named GetAXInfo
591that returns a printable summary of the TypeInfo from the ActiveX
592instance passed in. You can use this as an example of how to browse
593the TypeInfo provided, and there is also a copy of this function's
594output appended as a comment to the modules produced by the
595genaxmodule tool. Beyond that you'll need to consult the docs
596provided by the makers of the ActiveX control that you are using.
597
598
599
d14a1e28
RD
600Other Stuff
601-----------
602
603Instead of over a dozen separate extension modules linked together
604into a single extension module, the "core" module is now just a few
605extensions that are linked independently, and then merged together
606later into the main namespace via Python code.
607
e6a5dac6
RD
608Because of the above and also because of the way the new SWIG works,
609the "internal" module names have changed, but you shouldn't have been
610using them anyway so it shouldn't bother you. ;-)
d14a1e28 611
e6a5dac6
RD
612The help module no longer exists and the classes therein are now part
613of the core module imported with wxPython.wx or the wx package.
d14a1e28
RD
614
615wxPyDefaultPosition and wxPyDefaultSize are gone. Use the
616wxDefaultPosition and wxDefaultSize objects instead.
617
618Similarly, the wxSystemSettings backwards compatibiility aliases for
619GetSystemColour, GetSystemFont and GetSystemMetric have also gone into
620the bit-bucket. Use GetColour, GetFont and GetMetric instead.
621
622
ed8e1ecb
RD
623The wx.NO_FULL_REPAINT_ON_RESIZE style is now the default style for
624all windows. The name still exists for compatibility, but it is set
625to zero. If you want to disable the setting (so it matches the old
626default) then you need to use the new wx.FULL_REPAINT_ON_RESIZE style
627flag otherwise only the freshly exposed areas of the window will be
628refreshed.
d14a1e28 629
1f9b31fc
RD
630wxPyTypeCast has been removed. Since we've had the OOR (Original
631Object Return) for a couple years now there should be no need to use
632wxPyTypeCast at all.
d14a1e28 633
e6a5dac6
RD
634If you use the old wxPython package and wxPython.wx namespace then
635there are compatibility aliases for much of the above items.
78862f24
RD
636
637The wxWave class has been renamed to wxSound, and now has a slightly
638different API.
ce32c85b 639
45d67f33
RD
640wx.TaskbarIcon works on wxGTK-based platforms now, however you have to
641manage it a little bit more than you did before. Basically, the app
642will treat it like a top-level frame in that if the wx.TaskBarIcon
643still exists when all the frames are closed then the app will still
644not exit. You need to ensure that the wx.TaskBarIcon is destroyed
645when your last Frame is closed. For wxPython apps it is usually
646enough if your main frame object holds the only reference to the
647wx.TaskBarIcon, then when the frame is closed Python reference
648counting takes care of the rest.
649
33ab916f
RD
650Before Python 2.3 it was possible to pass a floating point object as a
651parameter to a function that expected an integer, and the
652PyArg_ParseTuple family of functions would automatically convert to
653integer by truncating the fractional portion of the number. With
654Python 2.3 that behavior was deprecated and a deprecation warning is
655raised when you pass a floating point value, (for example, calling
656wx.DC.DrawLineXY with floats for the position and size,) and lots of
657developers using wxPython had to scramble to change their code to call
658int() before calling wxPython methods. Recent changes in SWIG have
659moved the conversion out of PyArg_ParseTuple to custom code that SWIG
660generates. Since the default conversion fragment was a little too
661strict and didn't generate a very meaningful exception when it failed,
662I decided to use a custom fragment instead, and it turned out that
663it's very easy to allow floats to be converted again just like they
664used to be. So, in a nutshell, any numeric type that can be
665converted to an integer is now legal to be passed to SWIG wrapped
666functions in wxPython for parameters that are expecting an integer.
667If the object is not already an integer then it will be asked to
668convert itself to one. A similar conversion fragment is in place for
669parameters that expect floating point values.