[ Next: Bindings | Previous: Options | Contents ]

Tk Option Data Types

anchor
Legal values are points of the compass: "n", "ne", "e", "se", "s", "sw", "w", "nw", and also "center".
bitmap
There are eight built-in, named bitmaps: error,gray25, gray50, hourglass, info, questhead, question, warning. To specify an X bitmap filename, give the full path to the file, preceded with an "@", as in "@/usr/contrib/bitmap/gumby.bit". See page 164 of Ousterhout's book for details.
boolean
You can pass integers 0 or 1 or the stings "yes" or "no"
callback
This is any python function that takes no arguments. For example: def print_it(): print "hi there" fred["command"] = print_it
color
Colors can be given as the names of X colors in the rgb.txt file, or as strings representing RGB values in 4 bit: "#RGB", 8 bit: "#RRGGBB", 12 bit" "#RRRGGGBBB", or 16 bit "#RRRRGGGGBBBB" ranges, where R,G,B here represent any legal hex digit. See page 160 of Ousterhout's book for details.
cursor
The standard X cursor names from cursorfont.h can be used, without the XC_. For example to get a hand cursor ("XC_hand2"), use the string "hand2". You can also specify a bitmap and mask file of your own. See page 179 of Ousterhout's book.
distance
Screen distances can be specified in either pixels or absolute distances. Pixels are given as numbers and absolute distances as strings, with the trailing character denoting units: c for centimeters, i for inches, m for millimeters, p for printer's points. Ex: 3.5 inches is expressed as "3.5i".
font
Tk uses the standard X font name format, e.g. "-*-times-*-r-*-*-*-90-*-*-*-*-*-*". The xfontsel program for X windows can be handy in browsing and selecting fonts. See page 162-163 of Ousterhout's book for details.
geometry
This is a string of the form "widthxheight", where width and height are measured in pixels for most widgets (in characters for widgets displaying text). Example: fred["geometry"] = "200x100".
justify
Legal values are the strings: "left", "center", "right", and "fill".
region
This is a string with four space-delimited elements, each of which is a legal distance (see above). For example: "2 3 4 5" and "3i 2i 4.5i 2i" and "3c 2c 4c 10.43c" are all legal regions.
relief
Determines what the border style of a widget will be. Legal values are: "raised", "sunken", "flat", "groove", "ridge".
scrollcommand
This is almost always the set() method of some scrollbar Tkinter widget, but can be any widget method that takes a single argument. See example files for canvas-with-scrollbars.py for details.
wrap:
Must be one of: "none", "char" or "word".