4 <meta name="description" content="Pmw - a toolkit for building high-level compound widgets in Python">
5 <meta name="content" content="python, megawidget, mega widget, compound widget, gui, tkinter">
6 <title>Porting between different versions of Pmw</title>
9 <body bgcolor="#ffffff" text="#000000" link="#0000ee"
10 vlink="551a8b" alink="ff0000">
12 <h1 ALIGN="CENTER">Porting between different versions of Pmw</h1>
15 This document contains a brief guide to porting existing code
16 between different versions of Pmw. It includes significant
17 functionality changes but does not include bug fixes or compatible
18 enhancements. For details of all changes, see
19 <a href="changes.html">Changes to Pmw versions</a>.</p>
21 <p> <strong>Porting from 0.8.5 to 1.0, 1.1 and 1.2</strong></p>
23 <ul><li><p>Bug fix, documention and new features only. No
24 backwards-incompatible changes.</p>
27 <p> <strong>Porting from 0.8.4 to 0.8.5</strong></p>
29 <ul><li><p>Bug fix release only. No interface changes.</p>
32 <p> <strong>Porting from 0.8.3 to 0.8.4</strong></p>
34 <ul><li><p>Change the <code>setnaturalpagesize()</code> method of Pmw.NoteBook to
35 <code>setnaturalsize()</code> (to be consistent with Pmw.PanedWidget).</p>
38 <li><p>Change Pmw.excludefrombusycursor() to Pmw.setbusycursorattributes().
39 Replace busyCursorName option of Pmw.initialise() with
40 cursorName attribute of Pmw.setbusycursorattributes().</p>
43 <li><p>Several rarely used key bindings for Pmw.ScrolledListBox were
44 removed, changing the behaviour of the megawidget.</p>
47 <p> <strong>Porting from 0.8.1 to 0.8.3</strong></p>
49 <ul><li><p>The megawidgets Pmw.NoteBookR and Pmw.NoteBookS have been
50 replaced by a new Pmw.NoteBook. The interfaces are not
51 compatible, so see the Pmw.NoteBook reference manual for
55 <li><p>Change the get() method of Pmw.OptionMenu to getcurselection()
56 and the remove() method of Pmw.PanedWidget to delete().</p>
59 <li><p>If you use <strong>'end'</strong>, <strong>'default'</strong> or <strong>None</strong> in calls to the
60 index() method of several megawidgets, change these to
61 <strong>Pmw.END</strong>, <strong>Pmw.DEFAULT</strong> and <strong>Pmw.SELECT</strong>, respectively.</p>
64 <li><p>The exclude argument has been removed from Pmw.showbusycursor().
65 Use Pmw.excludefrombusycursor() instead.</p>
68 <li><p>The names of some of the positional arguments in the following
69 methods have changed: MegaArchetype.createcomponent(),
70 ButtonBox.insert(), ButtonBox.add(), MenuBar.addcascademenu(),
71 MenuBar.addmenuitem() and RadioSelect.add().</p>
74 <li><p>The Pmw.maxfontwidth() function has been removed. Use the
75 <code>font_measure()</code> Tkinter method, or if that has not yet been
77 <dl><dd><pre> someWidget.tk.call('font', 'measure', someFont, 'W')</pre></dd></dl>
81 <li><p>The Pmw.fontexists() function has been removed. This is
82 because, since Tk8.0, all fonts exist, so it no longer has
86 <p> <strong>Porting from 0.8 to 0.8.1</strong></p>
88 <ul><li><p>The Blt.Graph now supports blt2.4i which is not backwards
89 compatible with blt2.1.</p>
92 <p> <strong>Porting from 0.7 to 0.8</strong></p>
94 <ul><li><p>The <em>format</em> argument of Pmw.datestringtojdn() now defaults to
95 <strong>'ymd'</strong>. If you want to display dates with year, month and day
96 in a different order, add a <em>format</em> option to
97 Pmw.datestringtojdn() or to the <strong>datatype</strong> option of Pmw.Counter
98 or the <strong>validate</strong> option of Pmw.EntryField.</p>
101 <li><p>The justify() method from Pmw.ScrolledListBox has been removed.
102 Use the xview() or yview() methods instead.</p>
105 <li><p>Replace the getFrame() method of Pmw.ScrolledFrame with the
106 interior() method.</p>
109 <li><p>Replace the <strong>ringpadx</strong> and <strong>ringpady</strong> options of Pmw.Group by
110 padding the megawidget itself or by padding the children of the
114 <li><p>Replace the canvasbind() and canvasunbind() methods of
115 Pmw.Balloon with tagbind() and tagunbind().</p>
118 <li><p>The return value of Pmw.EntryField <strong>command</strong> callback is now
119 ignored. Previously, if the callback destroyed the megawidget,
120 it was required to return the string <strong>'break'</strong>, to work around a
121 problem in the event handling mechanism in Tkinter. With python
122 1.5.2, Tkinter has been fixed. Therefore, user-supplied
123 callback functions should use Pmw.hulldestroyed to check if the
124 megawidget has been destroyed before performing any operations
128 <li><p>If you require the <strong>'pmw1'</strong> fontScheme when running under
129 Microsoft Windows and Macintosh, you will need to set the Tk
130 font options manually.</p>
133 <p> <strong>Porting from 0.6 to 0.7</strong></p>
135 <ul><li><p>Replace the <strong>maxwidth</strong> option of Pmw.EntryField with the <strong>'max'</strong>
136 field of the <strong>validate</strong> option.</p>
139 <li><p>To specify that there should be no validation performed for a
140 Pmw.EntryField, the <strong>validate</strong> option must be None, not <strong>''</strong> as
144 <li><p>The date and time values of the Pmw.EntryField <strong>validate</strong> option
145 (such as <strong>'date_dmy'</strong> and <strong>'time24'</strong>, etc) are no longer supported.
146 Instead use a dictionary as the value of the <strong>validate</strong> option
147 with <strong>'date'</strong> or <strong>'time'</strong> in the <strong>'validator'</strong> field. Include
148 other fields in the dictionary to further specify the
152 <li><p>Pmw.Counter no longer supports the old date and time values for
153 the <strong>datatype</strong> option. Use a dictionary with a <strong>'counter'</strong>
154 field of <strong>'date'</strong> or <strong>'time'</strong> and other fields to further
155 specify the counting.</p>
158 <li><p>Pmw.Counter no longer supports the <strong>min</strong> and <strong>max</strong> options. Use
159 the Pmw.EntryField <strong>validate</strong> option instead.</p>
162 <li><p>The bbox method of Pmw.ScrolledListBox now refers to the bbox
163 method of the <strong>listbox</strong> component, not the <strong>hull</strong> component.</p>
166 <li><p>By default, Pmw.MenuBar now automatically adds hotkeys to menus
167 and menu items for keyboard traversal. To turn this off, use the
168 <code>hotkeys = 0</code> option.</p>
171 <li><p>The createcomponent() method now disallows the creation of
172 component names containing an underscore. If any component
173 names contain an underscore, rename them.</p>
176 <p> <strong>Porting from 0.5 to 0.6</strong></p>
178 <p> To port applications using Pmw version 0.5 to version 0.6, make
179 sure you are using python1.5. Then, simply change any lines in
180 your application like this:</p>
182 <dl><dd><pre> from PmwLazy import Pmw</pre></dd></dl>
186 <dl><dd><pre> import Pmw</pre></dd></dl>
188 <p> Also, if you have added the <code>lib</code> directory of a specific version
189 of Pmw to <code>sys.path</code> or <code>PYTHONPATH</code>, this can be removed, as long
190 as Pmw can now be found from the default path, such as in the
191 python <code>site-packages</code> directory.</p>
193 <p> <strong>Porting from 0.2 to 0.4</strong></p>
195 <ul><li><p>To get Pmw.0.2 default fonts (helvetica with bold italic menus
196 and italic scales) initialise with:</p>
197 <dl><dd><pre> Pmw.initialise(fontScheme = 'pmw1')</pre></dd></dl>
199 <p> If no <strong>fontScheme</strong> is given, the standard Tk default fonts are used.</p>
203 <li><p>Remove all calls to setdefaultresources(), usual(), keep(),
204 renameoptions(), ignore() and defineoptiontypes().</p>
207 <li><p>Move call to defineoptions() to before call to base class
208 constructor, create optiondefs tuple from self.defineoptions
209 arguments, then call defineoptions().</p>
212 <li><p>Remove resource class and name from optiondefs.</p>
215 <li><p>The last element in the optiondefs tuple (callback function)
216 must be given (may be None).</p>
219 <li><p>Add to classes currently without any options:</p>
220 <dl><dd><pre> optiondefs = ()
221 self.defineoptions(kw, optiondefs)</pre></dd></dl>
225 <li><p>Use createcomponent() to create components - this replaces the
226 calls to the component widget constructor and to
227 registercomponent().</p>
230 <li><p>Do not inherit from Pmw.LabeledWidget. Instead, replace with
231 Pmw.MegaWidget with labelpos and labelmargin options and a call
232 to self.createlabel(). If calling createlabel(), must replace
233 pack() with grid().</p>
236 <li><p>When calling a megawidget constructor, include subcomponent name when
237 setting subcomponent options (eg labeltext -> label_text)</p>
240 <li><p>The items option of ScrolledListBox is an initialisation option
241 only - use setlist() method after initialisation.</p>
244 <li><p>The <strong>autorelief</strong> option for Counter, EntryField, ScrolledText,
245 TextDialog has been removed.</p>
248 <li><p>ScrolledListBox.getcurselection() always returns a tuple of strings,
249 possibly of zero length.</p>
252 <li><p>Counter increment is always initialised to 1.</p>
255 <li><p>The <strong>'time'</strong> Counter <strong>datatype</strong> option has been replaced by
256 <strong>'timeN'</strong> and <strong>'time24'</strong>.</p>
259 <li><p>The <strong>'time'</strong> EntryField <strong>validate</strong> option has been replaced by
260 <strong>'timeN'</strong> and <strong>'time24'</strong>.</p>
263 <li><p>Replace call to initialise() with initialiseoptions(), removing
264 "kw" arg. This should always be the last line in a megawidget
268 <li><p>Replace hide() with withdraw().</p>
271 <li><p>Now need iconpos option for MessageDialogs with icon_bitmap option set.</p>
274 <li><p>Example megawidget class definition:</p>
277 <dl><dd><pre>class MyBigWidget(Pmw.MegaWidget):
278 def __init__(self, parent = None, **kw):
280 # Define the megawidget options.
282 ('errorbackground', 'pink', None),
283 ('maxwidth', 0, self._myfunc),
284 ('myinit', 'good', Pmw.INITOPT),
286 self.defineoptions(kw, optiondefs)
288 # Initialise the base class (after defining the options).
289 Pmw.MegaWidget.__init__(self, parent)
291 # Create the components.
292 interior = self.interior()
293 self._widget = self.createcomponent('component',
294 (('alias', 'component_alias'),), None,
295 Tkinter.Button, (interior,))
296 self._widget.grid(column=0, row=0, sticky='nsew')
298 self.createlabel(interior)
300 # Initialise instance variables.
301 self.deriveddummy = None
303 # Check keywords and initialise options.
304 self.initialiseoptions(MyBigWidget)
309 <center><P ALIGN="CENTER">
310 <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
315 <center><P ALIGN="CENTER">
318 - <a href="index.html">Home</a>