Back to index

python3.2  3.2.2
Namespaces | Classes | Functions | Variables
tkinter Namespace Reference

Namespaces

namespace  __main__
namespace  _fix
namespace  colorchooser
namespace  commondialog
namespace  constants
namespace  dialog
namespace  dnd
namespace  filedialog
namespace  font
namespace  messagebox
namespace  scrolledtext
namespace  simpledialog
namespace  test
namespace  tix
namespace  ttk

Classes

class  Event
class  Variable
class  StringVar
class  IntVar
class  DoubleVar
class  BooleanVar
class  Misc
class  CallWrapper
class  XView
class  YView
class  Wm
class  Tk
class  Pack
class  Place
class  Grid
class  BaseWidget
class  Widget
class  Toplevel
class  Button
class  Canvas
class  Checkbutton
class  Entry
class  Frame
class  Label
class  Listbox
class  Menu
class  Menubutton
class  Message
class  Radiobutton
class  Scale
class  Scrollbar
class  Text
class  _setit
class  OptionMenu
class  Image
class  PhotoImage
class  BitmapImage
class  Spinbox
class  LabelFrame
class  PanedWindow
class  Studbutton
class  Tributton

Functions

def _flatten
def _cnfmerge
def NoDefaultRoot
def _tkerror
def _exit
def mainloop
def getboolean
def Tcl
def AtEnd
def AtInsert
def AtSelFirst
def AtSelLast
def At
def image_names
def image_types
def _test

Variables

string __version__ = "$Revision$"
 TclError = _tkinter.TclError
int wantobjects = 1
tuple TkVersion = float(_tkinter.TK_VERSION)
tuple TclVersion = float(_tkinter.TCL_VERSION)
 READABLE = _tkinter.READABLE
 WRITABLE = _tkinter.WRITABLE
 EXCEPTION = _tkinter.EXCEPTION
int _support_default_root = 1
 _default_root = None
int _varnum = 0
 getint = int
 getdouble = float

Detailed Description

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 tkinter.constants 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()

Class Documentation

class tkinter::Event
Container for the properties of an event.

Instances of this type are generated if one of the following events occurs:

KeyPress, KeyRelease - for keyboard events
ButtonPress, ButtonRelease, Motion, Enter, Leave, MouseWheel - for mouse events
Visibility, Unmap, Map, Expose, FocusIn, FocusOut, Circulate,
Colormap, Gravity, Reparent, Property, Destroy, Activate,
Deactivate - for window events.

If a callback function for one of these events is registered
using bind, bind_all, bind_class, or tag_bind, the callback is
called with an Event as first argument. It will have the
following attributes (in braces are the event types for which
the attribute is valid):

    serial - serial number of event
num - mouse button pressed (ButtonPress, ButtonRelease)
focus - whether the window has the focus (Enter, Leave)
height - height of the exposed window (Configure, Expose)
width - width of the exposed window (Configure, Expose)
keycode - keycode of the pressed key (KeyPress, KeyRelease)
state - state of the event as a number (ButtonPress, ButtonRelease,
                        Enter, KeyPress, KeyRelease,
                        Leave, Motion)
state - state as a string (Visibility)
time - when the event occurred
x - x-position of the mouse
y - y-position of the mouse
x_root - x-position of the mouse on the screen
         (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
y_root - y-position of the mouse on the screen
         (ButtonPress, ButtonRelease, KeyPress, KeyRelease, Motion)
char - pressed character (KeyPress, KeyRelease)
send_event - see X/Windows documentation
keysym - keysym of the event as a string (KeyPress, KeyRelease)
keysym_num - keysym of the event as a number (KeyPress, KeyRelease)
type - type of the event as a number
widget - widget in which the event occurred
delta - delta of wheel movement (MouseWheel)

Definition at line 86 of file __init__.py.


Function Documentation

def tkinter._cnfmerge (   cnfs) [private]
Internal function.

Definition at line 66 of file __init__.py.

00066 
00067 def _cnfmerge(cnfs):
00068     """Internal function."""
00069     if isinstance(cnfs, dict):
00070         return cnfs
00071     elif isinstance(cnfs, (type(None), str)):
00072         return cnfs
00073     else:
00074         cnf = {}
00075         for c in _flatten(cnfs):
00076             try:
00077                 cnf.update(c)
00078             except (AttributeError, TypeError) as msg:
00079                 print("_cnfmerge: fallback due to:", msg)
00080                 for k, v in c.items():
00081                     cnf[k] = v
00082         return cnf
00083 
try: _cnfmerge = _tkinter._cnfmerge

Here is the call graph for this function:

Here is the caller graph for this function:

def tkinter._exit (   code = '0') [private]
Internal function. Calling it will throw the exception SystemExit.

Definition at line 149 of file __init__.py.

00149 
00150 def _exit(code='0'):
00151     """Internal function. Calling it will throw the exception SystemExit."""
00152     raise SystemExit(code)

Here is the caller graph for this function:

def tkinter._flatten (   seq) [private]
Internal function.

Definition at line 53 of file __init__.py.

00053 
00054 def _flatten(seq):
00055     """Internal function."""
00056     res = ()
00057     for item in seq:
00058         if isinstance(item, (tuple, list)):
00059             res = res + _flatten(item)
00060         elif item is not None:
00061             res = res + (item,)
00062     return res
00063 
try: _flatten = _tkinter._flatten

Here is the caller graph for this function:

def tkinter._test ( ) [private]

Definition at line 3691 of file __init__.py.

03691 
03692 def _test():
03693     root = Tk()
03694     text = "This is Tcl/Tk version %s" % TclVersion
03695     if TclVersion >= 8.1:
03696         text += "\nThis should be a cedilla: \xe7"
03697     label = Label(root, text=text)
03698     label.pack()
03699     test = Button(root, text="Click me!",
03700               command=lambda root=root: root.test.configure(
03701                   text="[%s]" % root.test['text']))
03702     test.pack()
03703     root.test = test
03704     quit = Button(root, text="QUIT", command=root.destroy)
03705     quit.pack()
03706     # The following three commands are needed so the window pops
03707     # up on top on Windows...
03708     root.iconify()
03709     root.update()
03710     root.deiconify()
03711     root.mainloop()

def tkinter._tkerror (   err) [private]
Internal function.

Definition at line 145 of file __init__.py.

00145 
00146 def _tkerror(err):
00147     """Internal function."""
00148     pass

def tkinter.At (   x,
  y = None 
)

Definition at line 2080 of file __init__.py.

02080 
02081 def At(x, y=None):
02082     if y is None:
02083         return '@%r' % (x,)
02084     else:
02085         return '@%r,%r' % (x, y)

def tkinter.AtEnd ( )

Definition at line 2069 of file __init__.py.

02069 
02070 def AtEnd():
    return 'end'
def tkinter.AtInsert (   args)

Definition at line 2071 of file __init__.py.

02071 
02072 def AtInsert(*args):
02073     s = 'insert'
02074     for a in args:
02075         if a: s = s + (' ' + a)
    return s

Definition at line 2076 of file __init__.py.

02076 
02077 def AtSelFirst():
    return 'sel.first'

Definition at line 2078 of file __init__.py.

02078 
02079 def AtSelLast():
    return 'sel.last'
def tkinter.getboolean (   s)
Convert true and false to integer values 1 and 0.

Definition at line 323 of file __init__.py.

00323 
00324 def getboolean(s):
00325     """Convert true and false to integer values 1 and 0."""
00326     return _default_root.tk.getboolean(s)
00327 
# Methods defined on both toplevel and interior widgets

Here is the caller graph for this function:

Definition at line 3289 of file __init__.py.

03289 
def image_names(): return _default_root.tk.call('image', 'names')

Definition at line 3290 of file __init__.py.

03290 
03291 def image_types(): return _default_root.tk.call('image', 'types')
03292 

def tkinter.mainloop (   n = 0)
Run the main loop of Tcl.

Definition at line 315 of file __init__.py.

00315 
00316 def mainloop(n=0):
00317     """Run the main loop of Tcl."""
00318     _default_root.tk.mainloop(n)

Here is the caller graph for this function:

Inhibit setting of default root window.

Call this function to inhibit that the first instance of
Tk is used for windows without an explicit parent window.

Definition at line 133 of file __init__.py.

00133 
00134 def NoDefaultRoot():
00135     """Inhibit setting of default root window.
00136 
00137     Call this function to inhibit that the first instance of
00138     Tk is used for windows without an explicit parent window.
00139     """
00140     global _support_default_root
00141     _support_default_root = 0
00142     global _default_root
00143     _default_root = None
00144     del _default_root

def tkinter.Tcl (   screenName = None,
  baseName = None,
  className = 'Tk',
  useTk = 0 
)

Definition at line 1767 of file __init__.py.

01767 
01768 def Tcl(screenName=None, baseName=None, className='Tk', useTk=0):
01769     return Tk(screenName, baseName, className, useTk)

Here is the caller graph for this function:


Variable Documentation

string tkinter.__version__ = "$Revision$"

Definition at line 33 of file __init__.py.

Definition at line 131 of file __init__.py.

Definition at line 130 of file __init__.py.

Definition at line 153 of file __init__.py.

tkinter.EXCEPTION = _tkinter.EXCEPTION

Definition at line 50 of file __init__.py.

Definition at line 321 of file __init__.py.

Definition at line 319 of file __init__.py.

Definition at line 48 of file __init__.py.

tkinter.TclError = _tkinter.TclError

Definition at line 40 of file __init__.py.

tuple tkinter.TclVersion = float(_tkinter.TCL_VERSION)

Definition at line 46 of file __init__.py.

tuple tkinter.TkVersion = float(_tkinter.TK_VERSION)

Definition at line 45 of file __init__.py.

Definition at line 43 of file __init__.py.

Definition at line 49 of file __init__.py.