File: porting.html

package info (click to toggle)
python-pmw 1.2-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,024 kB
  • ctags: 3,802
  • sloc: python: 17,143; makefile: 41
file content (325 lines) | stat: -rw-r--r-- 11,708 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325

    <html>
    <head>
    <meta name="description" content="Pmw - a toolkit for building high-level compound widgets in Python">
    <meta name="content" content="python, megawidget, mega widget, compound widget, gui, tkinter">
    <title>Porting between different versions of Pmw</title>
    </head>

    <body bgcolor="#ffffff" text="#000000" link="#0000ee"
	vlink="551a8b" alink="ff0000">

    <h1 ALIGN="CENTER">Porting between different versions of Pmw</h1>
    
<p>
    This document contains a brief guide to porting existing code
    between different versions of Pmw.  It includes significant
    functionality changes but does not include bug fixes or compatible
    enhancements.  For details of all changes, see
    <a href="changes.html">Changes to Pmw versions</a>.</p>

<p>    <strong>Porting from 0.8.5 to 1.0, 1.1 and 1.2</strong></p>

<ul><li><p>Bug fix, documention and new features only.  No
      backwards-incompatible changes.</p>

</li></ul>
<p>    <strong>Porting from 0.8.4 to 0.8.5</strong></p>

<ul><li><p>Bug fix release only. No interface changes.</p>

</li></ul>
<p>    <strong>Porting from 0.8.3 to 0.8.4</strong></p>

<ul><li><p>Change the <code>setnaturalpagesize()</code> method of Pmw.NoteBook to
      <code>setnaturalsize()</code> (to be consistent with Pmw.PanedWidget).</p>

</li>
<li><p>Change Pmw.excludefrombusycursor() to Pmw.setbusycursorattributes().
      Replace busyCursorName option of Pmw.initialise() with
      cursorName attribute of Pmw.setbusycursorattributes().</p>

</li>
<li><p>Several rarely used key bindings for Pmw.ScrolledListBox were
      removed, changing the behaviour of the megawidget.</p>

</li></ul>
<p>    <strong>Porting from 0.8.1 to 0.8.3</strong></p>

<ul><li><p>The megawidgets Pmw.NoteBookR and Pmw.NoteBookS have been
      replaced by a new Pmw.NoteBook.  The interfaces are not
      compatible, so see the Pmw.NoteBook reference manual for
      details.</p>

</li>
<li><p>Change the get() method of Pmw.OptionMenu to getcurselection()
      and the remove() method of Pmw.PanedWidget to delete().</p>

</li>
<li><p>If you use <strong>'end'</strong>, <strong>'default'</strong> or <strong>None</strong> in calls to the
      index() method of several megawidgets, change these to
      <strong>Pmw.END</strong>, <strong>Pmw.DEFAULT</strong> and <strong>Pmw.SELECT</strong>, respectively.</p>

</li>
<li><p>The exclude argument has been removed from Pmw.showbusycursor(). 
      Use Pmw.excludefrombusycursor() instead.</p>

</li>
<li><p>The names of some of the positional arguments in the following
      methods have changed:  MegaArchetype.createcomponent(),
      ButtonBox.insert(), ButtonBox.add(), MenuBar.addcascademenu(),
      MenuBar.addmenuitem() and RadioSelect.add().</p>

</li>
<li><p>The Pmw.maxfontwidth() function has been removed.  Use the
      <code>font_measure()</code> Tkinter method, or if that has not yet been
      implemented:</p>
<dl><dd><pre> someWidget.tk.call('font', 'measure', someFont, 'W')</pre></dd></dl>


</li>
<li><p>The Pmw.fontexists() function has been removed.  This is
      because, since Tk8.0, all fonts exist, so it no longer has
      any meaning.</p>

</li></ul>
<p>    <strong>Porting from 0.8 to 0.8.1</strong></p>

<ul><li><p>The Blt.Graph now supports blt2.4i which is not backwards
      compatible with blt2.1.</p>

</li></ul>
<p>    <strong>Porting from 0.7 to 0.8</strong></p>

<ul><li><p>The <em>format</em> argument of Pmw.datestringtojdn() now defaults to
      <strong>'ymd'</strong>.  If you want to display dates with year, month and day
      in a different order, add a <em>format</em> option to
      Pmw.datestringtojdn() or to the <strong>datatype</strong> option of Pmw.Counter
      or the <strong>validate</strong> option of Pmw.EntryField.</p>

</li>
<li><p>The justify() method from Pmw.ScrolledListBox has been removed. 
      Use the xview() or yview() methods instead.</p>

</li>
<li><p>Replace the getFrame() method of Pmw.ScrolledFrame with the
      interior() method.</p>

</li>
<li><p>Replace the <strong>ringpadx</strong> and <strong>ringpady</strong> options of Pmw.Group by
      padding the megawidget itself or by padding the children of the
      megawidget. </p>

</li>
<li><p>Replace the canvasbind() and canvasunbind() methods of
      Pmw.Balloon with tagbind() and tagunbind().</p>

</li>
<li><p>The return value of Pmw.EntryField <strong>command</strong> callback is now
      ignored.  Previously, if the callback destroyed the megawidget,
      it was required to return the string <strong>'break'</strong>, to work around a
      problem in the event handling mechanism in Tkinter.  With python
      1.5.2, Tkinter has been fixed.  Therefore, user-supplied
      callback functions should use Pmw.hulldestroyed to check if the
      megawidget has been destroyed before performing any operations
      on it.</p>

</li>
<li><p>If you require the <strong>'pmw1'</strong> fontScheme when running under
      Microsoft Windows and Macintosh, you will need to set the Tk
      font options manually.</p>

</li></ul>
<p>    <strong>Porting from 0.6 to 0.7</strong></p>

<ul><li><p>Replace the <strong>maxwidth</strong> option of Pmw.EntryField with the <strong>'max'</strong>
      field of the <strong>validate</strong> option.</p>

</li>
<li><p>To specify that there should be no validation performed for a
      Pmw.EntryField, the <strong>validate</strong> option must be None, not <strong>''</strong> as
      before.</p>

</li>
<li><p>The date and time values of the Pmw.EntryField <strong>validate</strong> option
      (such as <strong>'date_dmy'</strong> and <strong>'time24'</strong>, etc) are no longer supported. 
      Instead use a dictionary as the value of the <strong>validate</strong> option
      with <strong>'date'</strong> or <strong>'time'</strong> in the <strong>'validator'</strong> field.  Include
      other fields in the dictionary to further specify the
      validation.</p>

</li>
<li><p>Pmw.Counter no longer supports the old date and time values for
      the <strong>datatype</strong> option.  Use a dictionary with a <strong>'counter'</strong>
      field of <strong>'date'</strong> or <strong>'time'</strong> and other fields to further
      specify the counting.</p>

</li>
<li><p>Pmw.Counter no longer supports the <strong>min</strong> and <strong>max</strong> options.  Use
      the Pmw.EntryField <strong>validate</strong> option instead.</p>

</li>
<li><p>The bbox method of Pmw.ScrolledListBox now refers to the bbox
      method of the <strong>listbox</strong> component, not the <strong>hull</strong> component.</p>

</li>
<li><p>By default, Pmw.MenuBar now automatically adds hotkeys to menus
      and menu items for keyboard traversal.  To turn this off, use the
      <code>hotkeys = 0</code> option.</p>

</li>
<li><p>The createcomponent() method now disallows the creation of
      component names containing an underscore.  If any component
      names contain an underscore, rename them.</p>

</li></ul>
<p>    <strong>Porting from 0.5 to 0.6</strong></p>

<p>    To port applications using Pmw version 0.5 to version 0.6, make
    sure you are using python1.5.  Then, simply change any lines in
    your application like this:</p>

<dl><dd><pre> from PmwLazy import Pmw</pre></dd></dl>

<p>    to this:</p>

<dl><dd><pre> import Pmw</pre></dd></dl>

<p>    Also, if you have added the <code>lib</code> directory of a specific version
    of Pmw to <code>sys.path</code> or <code>PYTHONPATH</code>, this can be removed, as long
    as Pmw can now be found from the default path, such as in the
    python <code>site-packages</code> directory.</p>

<p>    <strong>Porting from 0.2 to 0.4</strong></p>

<ul><li><p>To get Pmw.0.2 default fonts (helvetica with bold italic menus
      and italic scales) initialise with:</p>
<dl><dd><pre> Pmw.initialise(fontScheme = 'pmw1')</pre></dd></dl>

<p>      If no <strong>fontScheme</strong> is given, the standard Tk default fonts are used.</p>


</li>
<li><p>Remove all calls to setdefaultresources(), usual(), keep(),
      renameoptions(), ignore() and defineoptiontypes().</p>

</li>
<li><p>Move call to defineoptions() to before call to base class
      constructor, create optiondefs tuple from self.defineoptions
      arguments, then call defineoptions().</p>

</li>
<li><p>Remove resource class and name from optiondefs.</p>

</li>
<li><p>The last element in the optiondefs tuple (callback function)
      must be given (may be None).</p>

</li>
<li><p>Add to classes currently without any options:</p>
<dl><dd><pre> optiondefs = ()
 self.defineoptions(kw, optiondefs)</pre></dd></dl>


</li>
<li><p>Use createcomponent() to create components - this replaces the
      calls to the component widget constructor and to
      registercomponent().</p>

</li>
<li><p>Do not inherit from Pmw.LabeledWidget.  Instead, replace with
      Pmw.MegaWidget with labelpos and labelmargin options and a call
      to self.createlabel().  If calling createlabel(), must replace
      pack() with grid().</p>

</li>
<li><p>When calling a megawidget constructor, include subcomponent name when
      setting subcomponent options (eg labeltext -&gt; label_text)</p>

</li>
<li><p>The items option of ScrolledListBox is an initialisation option
      only - use setlist() method after initialisation.</p>

</li>
<li><p>The <strong>autorelief</strong> option for Counter, EntryField, ScrolledText,
      TextDialog has been removed.</p>

</li>
<li><p>ScrolledListBox.getcurselection() always returns a tuple of strings,
      possibly of zero length.</p>

</li>
<li><p>Counter increment is always initialised to 1.</p>

</li>
<li><p>The <strong>'time'</strong> Counter <strong>datatype</strong> option has been replaced by
      <strong>'timeN'</strong> and <strong>'time24'</strong>.</p>

</li>
<li><p>The <strong>'time'</strong> EntryField <strong>validate</strong> option has been replaced by
      <strong>'timeN'</strong> and <strong>'time24'</strong>.</p>

</li>
<li><p>Replace call to initialise() with initialiseoptions(), removing
      "kw" arg.  This should always be the last line in a megawidget
      constructor.</p>

</li>
<li><p>Replace hide() with withdraw().</p>

</li>
<li><p>Now need iconpos option for MessageDialogs with icon_bitmap option set.</p>

</li>
<li><p>Example megawidget class definition:</p>

</li></ul>
<dl><dd><pre>class MyBigWidget(Pmw.MegaWidget):
    def __init__(self, parent = None, **kw):

        # Define the megawidget options.
        optiondefs = (
            ('errorbackground',   'pink',      None),
            ('maxwidth',          0,           self._myfunc),
            ('myinit',            'good',      Pmw.INITOPT),
        )
        self.defineoptions(kw, optiondefs)

        # Initialise the base class (after defining the options).
        Pmw.MegaWidget.__init__(self, parent)

        # Create the components.
        interior = self.interior()
        self._widget = self.createcomponent('component',
                (('alias', 'component_alias'),), None,
                Tkinter.Button, (interior,))
        self._widget.grid(column=0, row=0, sticky='nsew')

        self.createlabel(interior)

        # Initialise instance variables.
        self.deriveddummy = None

        # Check keywords and initialise options.
        self.initialiseoptions(MyBigWidget)
</pre></dd></dl>



    <center><P ALIGN="CENTER">
    <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
    </p></center>
    

    <font size=-1>
    <center><P ALIGN="CENTER">
    Pmw 1.2 -
     5 Aug 2003
     - <a href="index.html">Home</a>
    
    </p></center>
    </font>

    </body>
    </html>