Main Content

Tcl/Tk - why does the canvas widget use a display list?

Archive - Originally posted on "The Horse's Mouth" - 2009-06-01 08:59:36 - Graham Ellis

"Tcl/Tk uses a display list when you draw on a canvas widget." OK - so what does that really mean?

With most of the languages that we teach, any graphics you draw go straight into a frame buffer of a memory map that represents a frame buffer, so the earlier elements added to your graphic will be destructively overwritten by any later elements which happen to land on the same pixel. You have to be careful with drawing order, and if you need to remove a later element, you need to have a way of repairing the hole / repainting part of the screen when you do so

With Tcl/Tk, though, your elements are added into to a separate list in memory, in which all the graphic components are stored, and from which they can be replayed as and when required. This allows - you - for example to pick up and drag a component of your display without the need for a repaint.

Once again - Tcl and Tcl/Tk may be the oldest scripting language(s) that we teach, but they are very very neat and clever!