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
|
There is a new version of the "WPY" GUI programming module available on
ftp.interet.com in directory /pub/python. The version number is 0.30.
This is mirrored on ftp.python.org as /pub/python/wpy and on cwi.nl as
/pub/python/wpy.
This release changes the drawing model, and old WPY programs may need a
few changes to run on 0.30. See the file docs/incompat.txt. Also see
docs/changes.txt. Check your version number; it is in wpy.__version__
and wpy_tk.__version__.
In a normal MFC program, the user is responsible for refreshing the screen
when another window which covers it is removed (expose event) and when it
is scrolled and a new piece comes into view. This is accomplished in the
OnDraw() method. OnDraw() is called frequently by the MFC framework, and
it is necessary to write OnDraw() so it can accomplish partial updates
quickly.
The Tk drawing model is different. There are a set of drawn objects ("items")
in a canvas, and the Tk system handles the expose event itself. That is,
it redraws the screen when required. The support is in C, not Tcl.
I found it difficult to get really good fast scrolling on Windows NT doing
screen refresh in Python, and the code was annoying to write. So I changed
the WPY drawing model to be more like Tk. The OnDraw() method is the same
as before, and is responsible for drawing the whole view. But once drawn,
further screen refreshes are performed by the WPY system. It looks the same
as any MFC program, but OnDraw() is just called far fewer times.
This keeps the MFC model intact, but enables the programmer to write an
OnDraw() which simply redraws the whole view (always an option in MFC)
and still get good performance. Support for this is in C++.
I was really surprised that Tk handles redraw. I originally wrote WPY to
handle the expose event itself, and this resulted in poor Tk scrolling. This
was fixed in a prior release.
Based on this experience, it looks to me like Python will need to end
up with its own Python-ish GUI language. This can be based on MFC or
some other class system, but will not be identical.
Jim Ahlstrom
|