~toolpart/+junk/pythoncard

« back to all changes in this revision

Viewing changes to docs/migration_guide.txt

  • Committer: Bazaar Package Importer
  • Author(s): Mohammed Adnène Trojette
  • Date: 2006-11-12 17:52:13 UTC
  • mfrom: (2.1.5 feisty)
  • Revision ID: james.westby@ubuntu.com-20061112175213-tv8bnl6rtpa2qw1o
Tags: 0.8.1-8.1
* Non-maintainer upload.
* Fix path to findfiles, codeEditor and resourceEditor:
   + patch from Ernest ter Kuile <ernestjw@xs4all.nl>. (Closes: #397018)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
===============
 
2
Migration Guide
 
3
===============
 
4
 
 
5
Last changed 2004-08-25.
 
6
 
 
7
Introduction
 
8
------------
 
9
The purpose of this guide is to help people migrate their programs written for PythonCardPrototype release 0.7.3.1 to release 0.8. For a complete list of changes, please refer to the changelog.txt file. All the samples and tools included with PythonCard have already been updated to the new API, so you can also look at that code for examples. Some of the documentation included with PythonCard may still refer to the older APIs. If you spot a mistake, please email me at altis@semi-retired.com and I will update the documentation for the next release.
 
10
 
 
11
Version 0.8 is the first release on the way to finalizing the PythonCard API for a 1.0 release later this year or early 2005, whenever wxPython 2.6 is released. Like previous releases of the prototype package (PythonCardPrototype) you can expect changes from release to release until vesion 1.0 is done. One of the biggest changes to be aware of is that PythonCard is now keeping pace with each new wxPython release with the intent of basing the PythonCard 1.0 API on wxPython 2.6, thus the minimum requirements have been changed. wxPython 2.4.x will not be supported by PythonCard, there are simply too many changes and no effective way to maintain a code base that supports older wxPython releases. In addition, Python 2.2.x will not be supported.
 
12
 
 
13
 
 
14
Minimum Requirements
 
15
--------------------
 
16
Python 2.3 or later and wxPython 2.5.2.8 or later.
 
17
 
 
18
 
 
19
Package Name Change
 
20
-------------------
 
21
The main package name has changed from PythonCardPrototype to PythonCard. Since the package name has been changed it is possible to run older PythonCardPrototype programs even with the new package installed.
 
22
 
 
23
 
 
24
Resource File Changes
 
25
---------------------
 
26
The Stack class was removed, so the first line of your .rsrc.py file needs to have the 'stack' and 'Stack' strings replaced with 'application' and 'Application' as shown below.
 
27
::
 
28
 
 
29
 { 'stack':{ 'type':'Stack',
 
30
 
 
31
to
 
32
 
 
33
::
 
34
 
 
35
 { 'application':{ 'type':'Application',
 
36
 
 
37
In addition, in your source, self.stack.app references are now just self.application.
 
38
 
 
39
 
 
40
PythonCardApp Class Renamed
 
41
---------------------------
 
42
PythonCardApp was renamed to Application. The application initialization and startup code for your module will need to be updated to use the Application class. For example, here's the new code for the minimal sample.
 
43
 
 
44
::
 
45
 
 
46
 if __name__ == '__main__':
 
47
     app = model.Application(Minimal)
 
48
     app.MainLoop()
 
49
 
 
50
 
 
51
Events
 
52
------
 
53
openBackground was renamed to initialize, so rename your on_openBackground event handlers to on_initialize.
 
54
 
 
55
restore (inverse of minimize) and deactivate (inverse of activate) background window events were added.
 
56
 
 
57
The event binding and dispatch system was completely rewritten and simplified for release 0.8. If you were using any of the internal event classes or relying on how events were bound and dispatched, you should double-check your code to make sure it still works. A complete discussion of the changes is not appropriate for this document, so please bring up any issues you have on the pythoncard-users mailing list.
 
58
 
 
59
 
 
60
New-style Classes and Attributes (Properties)
 
61
---------------------------------------------
 
62
wxPython now uses new-style classes. This allowed the PythonCard components to be changed to use the property() function for attributes instead of __getattr__ and __setattr__ methods. Once again, this dramatically simplified the framework sources for components. In addition, we were able to remove get/set methods for position, size, foregroundColor, backgroundColor, etc. in the Background and CustomDialog classes and replace those get/set methods with attributes.
 
63
 
 
64
 
 
65
selection and stringSelection Attributes
 
66
----------------------------------------
 
67
The Choice, ComboBox, List, RadioGroup components were updated to use 'selection' and 'stringSelection' attributes instead of mixed-capability 'selected' and 'selection' attributes. If you were using these attributes previously, you will have to update both your source and resource files.
 
68
 
 
69
The correct way to get the result of a selection now is to use either the attribute 'selection' to retrieve the integer index, or 'stringSelection' for the text value; if you previously used functions such as getSelection() or getSelectionIndex() or getStringSelection() these need to be changed to use the attributes directly.
 
70
 
 
71
mixedCase Method Names
 
72
----------------------
 
73
All methods in PythonCard exposed to user code now use the mixedCase naming style to distinguish PythonCard methods from wxPython, which uses the CamelCase style for method names. In the PythonCard shell, the wxPython method names are suppressed in the auto-complete popup window.
 
74
 
 
75
 
 
76
wx Import Change
 
77
----------------
 
78
All imports from the wxPython.wx package have been changed to use the new wx package. For example:
 
79
::
 
80
 
 
81
 from wxPython import wx
 
82
 
 
83
has been changed to
 
84
 
 
85
::
 
86
 
 
87
 import wx
 
88
 
 
89
The biggest impact is that the wx prefix is no longer used (e.g. wx.wxFrame is now wx.Frame) in the framework or samples except for wxPython constants.
 
90
 
 
91
 
 
92
Module Names Changes
 
93
--------------------
 
94
 
 
95
::
 
96
 
 
97
 Old          New
 
98
 -----------------------------
 
99
 config.py    configuration.py
 
100
 pom.py       component.py
 
101
 res.py       resource.py
 
102
 
 
103
 
 
104
Added Modules
 
105
-------------
 
106
timer.py contains a simple wx.Timer class wrapper.
 
107
 
 
108
 
 
109
Deleted Modules
 
110
---------------
 
111
dispatch.py
 
112
 
 
113
 
 
114
Dialogs
 
115
-------
 
116
The dialog module is now a thin wrapper around the wx.lib.dialogs module. The biggest change to your code is that the result of dialogs is now a DialogResults class instead of a dictionary. See the dialogs sample for examples of usage, but in general if you had something like result['accepted'] it will now be result.accepted.
 
117
 
 
118
The order of the message and title args for any dialogs that take both has been reversed from previous versions of PythonCard. The message arg comes before title now. For example, 
 
119
::
 
120
 
 
121
 dialog.singleChoiceDialog(self, "message", "title", ['one', 'two', 'three'])
 
122
 
 
123
Any optional style args now use wx constants rather the old dialog module aliases. For example, you'll need to use wx.TE_PASSWORD or wx.TE_MULTILINE for the textEntryDialog if you want one of those styles.
 
124
 
 
125
Calendar Component
 
126
------------------
 
127
The Calendar component was changed to use the CAL_SEQUENTIAL_MONTH_SELECTION style. A style attribute may need to be added to the Calendar component in future releases to allow different calendar styles to be used.
 
128
 
 
129
 
 
130
Image Component
 
131
---------------
 
132
PythonCard now uses wx.lib.statbmp.GenStaticBitmap on GTK for the Image component so that the Image component can get mouse events on all platforms. If you want to use a bitmap with transparency, then you'll also want to use the Image component to get the same appearance on all platforms.
 
133
 
 
134
 
 
135
StatusBar
 
136
---------
 
137
statusbar.StatusBar a direct subclass of wx.StatusBar so it is now possible to provide your own StatusBar subclass to use instead of the default. See the createStatusBar method in model.py
 
138
 
 
139
 
 
140
Miscellaneous
 
141
-------------
 
142
Renamed stc-styles.rc.cfg to stc-styles.cfg, but this shouldn't impact any user programs.
 
143