Tkinter vs wxPython: your opinions?

Fredrik Lundh fredrik at effbot.org
Sun Jan 28 10:19:54 EST 2001


Horst Gassner wrote:
> Tkinter 3000 raised my hopes because it should be 2-10 times faster in
> "a typical application". But when will the first final release be
> available? How much is the perfomance boost for canvas widgets (I use
> them in my table and tree widget)?

Tkinter performance is tricky, since there are so many parts
involved.

-- Data conversion (from Python objects to Tcl/Tk objects)
is expensive.  Some tips:

- Use move/scale to modify canvas items instead of
  delete/create.
- To temporarily hide a canvas item, move it outside
  the view, instead of deleting it.
- Reuse photoimage objects.
- Pass integers instead of floating point values.
- Use tags to apply operations to groups of items.

(Tkinter 3000 notes: the new binding layer use a couple of
tricks to speed up the data conversion between 2-10 times.
If you need more speed, you have to roll your own WCK-
based widget.  The WCK drawing layer uses Python objects
directly)

-- The canvas widget doesn't redraw itself immediately
after changes.   Instead, it waits until you get back to
the event loop, just in case you need to do more changes.
Adding a call to update_idletasks() can really speed things
up here.

(Tkinter 3000 notes: the new bindings won't help here.
However, WCK widgets can redraw themselves when-
ever they want).

-- The canvas is double-buffered.  Tk draws the content to
a pixmap before copying things to the screen.  This can be
costly, especially if you're using large canvases.

(one related problem is that if you're making small updates
in different parts of the canvas at the same time, Tkinter
may have to redraw everything in between as well.  Again,
calling update_idletasks() after you've updated each region
can help).

(Tkinter 3000 notes: WCK widgets don't have to use double-
buffering -- and if they do, they don't have to use double-
buffering on the entire widget).

:::

As for a release date, the current WCK preview sure qualifies
as "usable".  I hope to have an alpha out there before the end
of this month, and don't expect the move to "1.0" to take more
than a few weeks.

(fwiw, the API hasn't changed since the last preview, so you
can treat the preview as "alpha 0" if you want...)

Cheers /F





More information about the Python-list mailing list