Tkinter

Wrapper functions for Tcl/Tk.

Tkinter provides classes which allow the display, positioning and control of widgets. Toplevel widgets are Tk and Toplevel. Other widgets are Frame, Label, Entry, Text, Canvas, Button, Radiobutton, Checkbutton, Scale, Listbox, Scrollbar, OptionMenu, Spinbox LabelFrame and PanedWindow.

Properties of the widgets are specified with keyword arguments. Keyword arguments have the same name as the corresponding resource under Tk.

Widgets are positioned with one of the geometry managers Place, Pack or Grid. These managers can be called with methods place, pack, grid available in every Widget.

Actions are bound to events by resources (e.g. keyword argument command) or with the method bind.

Example (Hello, World): import Tkinter from Tkconstants import * tk = Tkinter.Tk() frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2) frame.pack(fill=BOTH,expand=1) label = Tkinter.Label(frame, text=”Hello, World”) label.pack(fill=X, expand=1) button = Tkinter.Button(frame,text=”Exit”,command=tk.destroy) button.pack(side=BOTTOM) tk.mainloop()

Functions

At(x[, y])
AtEnd()
AtInsert(*args)
AtSelFirst()
AtSelLast()
NoDefaultRoot() Inhibit setting of default root window.
Tcl([screenName, baseName, className, useTk])
getboolean(s) Convert true and false to integer values 1 and 0.
image_names()
image_types()
mainloop([n]) Run the main loop of Tcl.

Classes

BaseWidget(master, widgetName[, cnf, kw, extra]) Internal class.
BitmapImage([name, cnf, master]) Widget which can display a bitmap.
BooleanType alias of bool
BooleanVar([master, value, name]) Value holder for boolean variables.
BufferType alias of buffer
BuiltinFunctionType alias of builtin_function_or_method
BuiltinMethodType alias of builtin_function_or_method
Button([master, cnf]) Button widget.
CallWrapper(func, subst, widget) Internal class.
Canvas([master, cnf]) Canvas widget to display graphical elements like lines or text.
Checkbutton([master, cnf]) Checkbutton widget which is either in on- or off-state.
ClassType alias of classobj
CodeType alias of code
ComplexType alias of complex
DictProxyType alias of dictproxy
DictType alias of dict
DictionaryType alias of dict
DoubleVar([master, value, name]) Value holder for float variables.
EllipsisType alias of ellipsis
Entry([master, cnf]) Entry widget which allows displaying simple text.
Event Container for the properties of an event.
FileType alias of file
FloatType alias of float
Frame([master, cnf]) Frame widget which may contain other widgets and can have a 3D border.
FrameType alias of frame
FunctionType alias of function
GeneratorType alias of generator
GetSetDescriptorType alias of getset_descriptor
Grid Geometry manager Grid.
Image(imgtype[, name, cnf, master]) Base class for images.
InstanceType alias of instance
IntType alias of int
IntVar([master, value, name]) Value holder for integer variables.
Label([master, cnf]) Label widget which can display text and bitmaps.
LabelFrame([master, cnf]) labelframe widget.
LambdaType alias of function
ListType alias of list
Listbox([master, cnf]) Listbox widget which can display a list of strings.
LongType alias of long
MemberDescriptorType alias of member_descriptor
Menu([master, cnf]) Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.
Menubutton([master, cnf]) Menubutton widget, obsolete since Tk8.0.
Message([master, cnf]) Message widget to display multiline text.
MethodType alias of instancemethod
Misc Internal class.
ModuleType alias of module
NoneType
NotImplementedType
ObjectType alias of object
OptionMenu(master, variable, value, *values, ...) OptionMenu which allows the user to select a value from a menu.
Pack Geometry manager Pack.
PanedWindow([master, cnf]) panedwindow widget.
PhotoImage([name, cnf, master]) Widget which can display colored images in GIF, PPM/PGM format.
Place Geometry manager Place.
Radiobutton([master, cnf]) Radiobutton widget which shows only one of several buttons in on-state.
Scale([master, cnf]) Scale widget which can display a numerical scale.
Scrollbar([master, cnf]) Scrollbar widget which displays a slider at a certain position.
SliceType alias of slice
Spinbox([master, cnf]) spinbox widget.
StringType alias of str
StringVar([master, value, name]) Value holder for strings variables.
Studbutton([master, cnf])
Text([master, cnf]) Text widget which can display text in various forms.
Tk([screenName, baseName, className, useTk, ...]) Toplevel widget of Tk which represents mostly the main window of an application.
Toplevel([master, cnf]) Toplevel widget, e.g.
TracebackType alias of traceback
Tributton([master, cnf])
TupleType alias of tuple
TypeType alias of type
UnboundMethodType alias of instancemethod
UnicodeType alias of unicode
Variable([master, value, name]) Class to define value holders for e.g.
Widget(master, widgetName[, cnf, kw, extra]) Internal class.
Wm Provides functions for the communication with the window manager.
XRangeType alias of xrange
XView Mix-in class for querying and changing the horizontal position of a widget’s window.
YView Mix-in class for querying and changing the vertical position of a widget’s window.
getdouble alias of float
getint alias of int

Exceptions

TclError