| 1 | |
| 2 | <html> |
| 3 | <head> |
| 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> |
| 7 | </head> |
| 8 | |
| 9 | <body bgcolor="#ffffff" text="#000000" link="#0000ee" |
| 10 | vlink="551a8b" alink="ff0000"> |
| 11 | |
| 12 | <h1 ALIGN="CENTER">Porting between different versions of Pmw</h1> |
| 13 | |
| 14 | <p> |
| 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> |
| 20 | |
| 21 | <p> <strong>Porting from 0.8.5 to 1.0, 1.1 and 1.2</strong></p> |
| 22 | |
| 23 | <ul><li><p>Bug fix, documention and new features only. No |
| 24 | backwards-incompatible changes.</p> |
| 25 | |
| 26 | </li></ul> |
| 27 | <p> <strong>Porting from 0.8.4 to 0.8.5</strong></p> |
| 28 | |
| 29 | <ul><li><p>Bug fix release only. No interface changes.</p> |
| 30 | |
| 31 | </li></ul> |
| 32 | <p> <strong>Porting from 0.8.3 to 0.8.4</strong></p> |
| 33 | |
| 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> |
| 36 | |
| 37 | </li> |
| 38 | <li><p>Change Pmw.excludefrombusycursor() to Pmw.setbusycursorattributes(). |
| 39 | Replace busyCursorName option of Pmw.initialise() with |
| 40 | cursorName attribute of Pmw.setbusycursorattributes().</p> |
| 41 | |
| 42 | </li> |
| 43 | <li><p>Several rarely used key bindings for Pmw.ScrolledListBox were |
| 44 | removed, changing the behaviour of the megawidget.</p> |
| 45 | |
| 46 | </li></ul> |
| 47 | <p> <strong>Porting from 0.8.1 to 0.8.3</strong></p> |
| 48 | |
| 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 |
| 52 | details.</p> |
| 53 | |
| 54 | </li> |
| 55 | <li><p>Change the get() method of Pmw.OptionMenu to getcurselection() |
| 56 | and the remove() method of Pmw.PanedWidget to delete().</p> |
| 57 | |
| 58 | </li> |
| 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> |
| 62 | |
| 63 | </li> |
| 64 | <li><p>The exclude argument has been removed from Pmw.showbusycursor(). |
| 65 | Use Pmw.excludefrombusycursor() instead.</p> |
| 66 | |
| 67 | </li> |
| 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> |
| 72 | |
| 73 | </li> |
| 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 |
| 76 | implemented:</p> |
| 77 | <dl><dd><pre> someWidget.tk.call('font', 'measure', someFont, 'W')</pre></dd></dl> |
| 78 | |
| 79 | |
| 80 | </li> |
| 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 |
| 83 | any meaning.</p> |
| 84 | |
| 85 | </li></ul> |
| 86 | <p> <strong>Porting from 0.8 to 0.8.1</strong></p> |
| 87 | |
| 88 | <ul><li><p>The Blt.Graph now supports blt2.4i which is not backwards |
| 89 | compatible with blt2.1.</p> |
| 90 | |
| 91 | </li></ul> |
| 92 | <p> <strong>Porting from 0.7 to 0.8</strong></p> |
| 93 | |
| 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> |
| 99 | |
| 100 | </li> |
| 101 | <li><p>The justify() method from Pmw.ScrolledListBox has been removed. |
| 102 | Use the xview() or yview() methods instead.</p> |
| 103 | |
| 104 | </li> |
| 105 | <li><p>Replace the getFrame() method of Pmw.ScrolledFrame with the |
| 106 | interior() method.</p> |
| 107 | |
| 108 | </li> |
| 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 |
| 111 | megawidget. </p> |
| 112 | |
| 113 | </li> |
| 114 | <li><p>Replace the canvasbind() and canvasunbind() methods of |
| 115 | Pmw.Balloon with tagbind() and tagunbind().</p> |
| 116 | |
| 117 | </li> |
| 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 |
| 125 | on it.</p> |
| 126 | |
| 127 | </li> |
| 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> |
| 131 | |
| 132 | </li></ul> |
| 133 | <p> <strong>Porting from 0.6 to 0.7</strong></p> |
| 134 | |
| 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> |
| 137 | |
| 138 | </li> |
| 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 |
| 141 | before.</p> |
| 142 | |
| 143 | </li> |
| 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 |
| 149 | validation.</p> |
| 150 | |
| 151 | </li> |
| 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> |
| 156 | |
| 157 | </li> |
| 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> |
| 160 | |
| 161 | </li> |
| 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> |
| 164 | |
| 165 | </li> |
| 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> |
| 169 | |
| 170 | </li> |
| 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> |
| 174 | |
| 175 | </li></ul> |
| 176 | <p> <strong>Porting from 0.5 to 0.6</strong></p> |
| 177 | |
| 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> |
| 181 | |
| 182 | <dl><dd><pre> from PmwLazy import Pmw</pre></dd></dl> |
| 183 | |
| 184 | <p> to this:</p> |
| 185 | |
| 186 | <dl><dd><pre> import Pmw</pre></dd></dl> |
| 187 | |
| 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> |
| 192 | |
| 193 | <p> <strong>Porting from 0.2 to 0.4</strong></p> |
| 194 | |
| 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> |
| 198 | |
| 199 | <p> If no <strong>fontScheme</strong> is given, the standard Tk default fonts are used.</p> |
| 200 | |
| 201 | |
| 202 | </li> |
| 203 | <li><p>Remove all calls to setdefaultresources(), usual(), keep(), |
| 204 | renameoptions(), ignore() and defineoptiontypes().</p> |
| 205 | |
| 206 | </li> |
| 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> |
| 210 | |
| 211 | </li> |
| 212 | <li><p>Remove resource class and name from optiondefs.</p> |
| 213 | |
| 214 | </li> |
| 215 | <li><p>The last element in the optiondefs tuple (callback function) |
| 216 | must be given (may be None).</p> |
| 217 | |
| 218 | </li> |
| 219 | <li><p>Add to classes currently without any options:</p> |
| 220 | <dl><dd><pre> optiondefs = () |
| 221 | self.defineoptions(kw, optiondefs)</pre></dd></dl> |
| 222 | |
| 223 | |
| 224 | </li> |
| 225 | <li><p>Use createcomponent() to create components - this replaces the |
| 226 | calls to the component widget constructor and to |
| 227 | registercomponent().</p> |
| 228 | |
| 229 | </li> |
| 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> |
| 234 | |
| 235 | </li> |
| 236 | <li><p>When calling a megawidget constructor, include subcomponent name when |
| 237 | setting subcomponent options (eg labeltext -> label_text)</p> |
| 238 | |
| 239 | </li> |
| 240 | <li><p>The items option of ScrolledListBox is an initialisation option |
| 241 | only - use setlist() method after initialisation.</p> |
| 242 | |
| 243 | </li> |
| 244 | <li><p>The <strong>autorelief</strong> option for Counter, EntryField, ScrolledText, |
| 245 | TextDialog has been removed.</p> |
| 246 | |
| 247 | </li> |
| 248 | <li><p>ScrolledListBox.getcurselection() always returns a tuple of strings, |
| 249 | possibly of zero length.</p> |
| 250 | |
| 251 | </li> |
| 252 | <li><p>Counter increment is always initialised to 1.</p> |
| 253 | |
| 254 | </li> |
| 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> |
| 257 | |
| 258 | </li> |
| 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> |
| 261 | |
| 262 | </li> |
| 263 | <li><p>Replace call to initialise() with initialiseoptions(), removing |
| 264 | "kw" arg. This should always be the last line in a megawidget |
| 265 | constructor.</p> |
| 266 | |
| 267 | </li> |
| 268 | <li><p>Replace hide() with withdraw().</p> |
| 269 | |
| 270 | </li> |
| 271 | <li><p>Now need iconpos option for MessageDialogs with icon_bitmap option set.</p> |
| 272 | |
| 273 | </li> |
| 274 | <li><p>Example megawidget class definition:</p> |
| 275 | |
| 276 | </li></ul> |
| 277 | <dl><dd><pre>class MyBigWidget(Pmw.MegaWidget): |
| 278 | def __init__(self, parent = None, **kw): |
| 279 | |
| 280 | # Define the megawidget options. |
| 281 | optiondefs = ( |
| 282 | ('errorbackground', 'pink', None), |
| 283 | ('maxwidth', 0, self._myfunc), |
| 284 | ('myinit', 'good', Pmw.INITOPT), |
| 285 | ) |
| 286 | self.defineoptions(kw, optiondefs) |
| 287 | |
| 288 | # Initialise the base class (after defining the options). |
| 289 | Pmw.MegaWidget.__init__(self, parent) |
| 290 | |
| 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') |
| 297 | |
| 298 | self.createlabel(interior) |
| 299 | |
| 300 | # Initialise instance variables. |
| 301 | self.deriveddummy = None |
| 302 | |
| 303 | # Check keywords and initialise options. |
| 304 | self.initialiseoptions(MyBigWidget) |
| 305 | </pre></dd></dl> |
| 306 | |
| 307 | |
| 308 | |
| 309 | <center><P ALIGN="CENTER"> |
| 310 | <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5> |
| 311 | </p></center> |
| 312 | |
| 313 | |
| 314 | <font size=-1> |
| 315 | <center><P ALIGN="CENTER"> |
| 316 | Pmw 1.2 - |
| 317 | 5 Aug 2003 |
| 318 | - <a href="index.html">Home</a> |
| 319 | |
| 320 | </p></center> |
| 321 | </font> |
| 322 | |
| 323 | </body> |
| 324 | </html> |
| 325 | |