3.2 The Graphics Engine, Tickles, and Widget Messages

Widget objects as well as instances of other classes defined in the Tk module are built as object oriented frontends to a single graphical agent, the graphics engine.

3.2.1 The Graphics Engine

The graphics engine receives messages and executes them. By executing a message the engine creates widgets, configures the appearance and behavior of widgets, or computes a geometry for the layout of a widget on the screen.


The messages the engine understands are tickles. The procedures Tk.send and Tk.batch take a tickle or a list of tickles and send it to the graphics engine. We use these two procedures especially to send tickles for geometry management, as is discussed in Chapter 4.

translating object messages to tickles

Messages sent to widgets and other objects of the Tk interface are translated in a straightforward fashion to tickles. These tickles are then forwarded to the graphics engine.

3.2.2 Tickles and Widget Messages

Tickles are used to describe messages for the graphics engine. A tickle is either a boolean value, the name unit, a virtual string, a record that has neither a name as label nor as feature, or a tickle object. A tickle object is any instance of a class that the Tk module provides, unless otherwise mentioned (the only exception is the class Tk.listener, see Section 5.6).

An initialization message with label tkInit must be a record without integer features. The field of a feature must be a tickle. Only the special features parent, action, url, and args may take different values. These features we will discuss later.


To the features we refer to as configuration options, or for short as options. Their values we refer to as option values.

commands and arguments

A message with label tk must be a record with at least a single integer feature and maybe some other integer features and some options. The value of the first integer feature we call the command, whereas we refer to the remaining values for the integer features as arguments. For example, in the message

tk(set active background:purple)

set is the command, active is the single argument, and background is an option with value purple.

3.2.3 Translating Tickles

The graphics engine does not understand tickles but strings that follow a particular structure. This means that each tickle sent to the graphics engine is first translated to a string. The translation is generic, for our purposes here it suffices to give a short example. The full translation details can be found in Chapter 28 of ``System Modules''.

For example,

example("test" 1 2.0 side:left(right:true) fill:x)

is translated to

"example test 1 2.0 -side left -right 1 -fill x"

That is, a record is translated to a string consisting of the label and the features and the translation of the fields. Atomic features are prepended by a "-" and integer features are ignored.

3.2.4 Special Tickles

Additionally, special tickles are supported (see Table 3.1). Their usage becomes clear in the examples that are presented in this document.





o(10 12 fill:red)

10 12 -fill red


see Figure 6.1

l(red green blue)

[red green blue]


list of tickles

q(red green blue)

{red green blue}


see Figure 6.1

s(red green blue)

"red green blue"


string of tickles

p(4 7 linestart)

{4.7 linestart}


see *

b([a(b:1) c(d:2)])

a -b 1 c -d 2


see *

v(1#"\nno quote")

1\nno quote

virtual string

verbatim virtual strings

c(255 128 0)



see Figure 5.9

d(pack(grid row:4))

grid -row 4


skip record label

Table 3.1: Examples of special tickles.

Christian Schulte
Version 1.4.0 (20080702)