Module Tkinter
[hide private]
[frames] | no frames]

Module Tkinter

source code

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()

Classes [hide private]
  BaseWidget
Internal class.
  BitmapImage
Widget which can display a bitmap.
  BooleanVar
Value holder for boolean variables.
  Button
Button widget.
  CallWrapper
Internal class.
  Canvas
Canvas widget to display graphical elements like lines or text.
  Checkbutton
Checkbutton widget which is either in on- or off-state.
  DoubleVar
Value holder for float variables.
  Entry
Entry widget which allows to display simple text.
  Event
Container for the properties of an event.
  Grid
Geometry manager Grid.
  Image
Base class for images.
  IntVar
Value holder for integer variables.
  Label
Label widget which can display text and bitmaps.
  LabelFrame
labelframe widget.
  Listbox
Listbox widget which can display a list of strings.
  Menu
Menu widget which allows to display menu bars, pull-down menus and pop-up menus.
  Menubutton
Menubutton widget, obsolete since Tk8.0.
  Message
Message widget to display multiline text.
  OptionMenu
OptionMenu which allows the user to select a value from a menu.
  Pack
Geometry manager Pack.
  PanedWindow
panedwindow widget.
  PhotoImage
Widget which can display colored images in GIF, PPM/PGM format.
  Place
Geometry manager Place.
  Radiobutton
Radiobutton widget which shows only one of several buttons in on-state.
  Scale
Scale widget which can display a numerical scale.
  Scrollbar
Scrollbar widget which displays a slider at a certain position.
  Spinbox
spinbox widget.
  StringVar
Value holder for strings variables.
  Studbutton
  Text
Text widget which can display text in various forms.
  Tk
Toplevel widget of Tk which represents mostly the main window of an appliation.
  Toplevel
Toplevel widget, e.g.
  Tributton
  Variable
Class to define value holders for e.g.
  Widget
Internal class.
  Wm
Provides functions for the communication with the window manager.
  _setit
Internal class.

Functions [hide private]
  At(x, y=None)
  AtEnd()
  AtInsert(*args)
  AtSelFirst()
  AtSelLast()
  NoDefaultRoot()
Inhibit setting of default root window.
  Tcl(screenName=None, baseName=None, className='Tk', useTk=0)
  _cnfmerge(cnfs)
Internal function.
  _exit(code='0')
Internal function.
  _test()
  _tkerror(err)
Internal function.
  getboolean(s)
Convert true and false to integer values 1 and 0.
  image_names()
  image_types()
  mainloop(n=0)
Run the main loop of Tcl.

Variables [hide private]
  ACTIVE = 'active'
  ALL = 'all'
  ANCHOR = 'anchor'
  ARC = 'arc'
  BASELINE = 'baseline'
  BEVEL = 'bevel'
  BOTH = 'both'
  BOTTOM = 'bottom'
  BROWSE = 'browse'
  BUTT = 'butt'
  CASCADE = 'cascade'
  CENTER = 'center'
  CHAR = 'char'
  CHECKBUTTON = 'checkbutton'
  CHORD = 'chord'
  COMMAND = 'command'
  CURRENT = 'current'
  DISABLED = 'disabled'
  DOTBOX = 'dotbox'
  E = 'e'
  END = 'end'
  EW = 'ew'
  EXCEPTION = 8
  EXTENDED = 'extended'
  FALSE = 0
  FIRST = 'first'
  FLAT = 'flat'
  GROOVE = 'groove'
  HIDDEN = 'hidden'
  HORIZONTAL = 'horizontal'
  INSERT = 'insert'
  INSIDE = 'inside'
  LAST = 'last'
  LEFT = 'left'
  MITER = 'miter'
  MOVETO = 'moveto'
  MULTIPLE = 'multiple'
  N = 'n'
  NE = 'ne'
  NO = 0
  NONE = 'none'
  NORMAL = 'normal'
  NS = 'ns'
  NSEW = 'nsew'
  NUMERIC = 'numeric'
  NW = 'nw'
  OFF = 0
  ON = 1
  OUTSIDE = 'outside'
  PAGES = 'pages'
  PIESLICE = 'pieslice'
  PROJECTING = 'projecting'
  RADIOBUTTON = 'radiobutton'
  RAISED = 'raised'
  READABLE = 2
  RIDGE = 'ridge'
  RIGHT = 'right'
  ROUND = 'round'
  S = 's'
  SCROLL = 'scroll'
  SE = 'se'
  SEL = 'sel'
  SEL_FIRST = 'sel.first'
  SEL_LAST = 'sel.last'
  SEPARATOR = 'separator'
  SINGLE = 'single'
  SOLID = 'solid'
  SUNKEN = 'sunken'
  SW = 'sw'
  StringTypes = (<type 'str'>, <type 'unicode'>)
  TOP = 'top'
  TRUE = 1
  TclVersion = 8.4000000000000004
  TkVersion = 8.4000000000000004
  UNDERLINE = 'underline'
  UNITS = 'units'
  VERTICAL = 'vertical'
  W = 'w'
  WORD = 'word'
  WRITABLE = 4
  X = 'x'
  Y = 'y'
  YES = 1
  _MacOS = None
  __version__ = '$Revision: 1.181.2.2 $'
  _default_root = None
  _support_default_root = 1
  _varnum = 0
  wantobjects = 1

Function Details [hide private]

At(x, y=None)

source code 
None

AtEnd()

source code 
None

AtInsert(*args)

source code 
None

AtSelFirst()

source code 
None

AtSelLast()

source code 
None

NoDefaultRoot()

source code 

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.

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

source code 
None

_cnfmerge(cnfs)

source code 
Internal function.

_exit(code='0')

source code 
Internal function. Calling it will throw the exception SystemExit.

_test()

source code 
None

_tkerror(err)

source code 
Internal function.

getboolean(s)

source code 
Convert true and false to integer values 1 and 0.

image_names()

source code 
None

image_types()

source code 
None

mainloop(n=0)

source code 
Run the main loop of Tcl.

Variables Details [hide private]

ACTIVE

None
Value:
'active'                                                               
      

ALL

None
Value:
'all'                                                                  
      

ANCHOR

None
Value:
'anchor'                                                               
      

ARC

None
Value:
'arc'                                                                  
      

BASELINE

None
Value:
'baseline'                                                             
      

BEVEL

None
Value:
'bevel'                                                                
      

BOTH

None
Value:
'both'                                                                 
      

BOTTOM

None
Value:
'bottom'                                                               
      

BROWSE

None
Value:
'browse'                                                               
      

BUTT

None
Value:
'butt'                                                                 
      

CASCADE

None
Value:
'cascade'                                                              
      

CENTER

None
Value:
'center'                                                               
      

CHAR

None
Value:
'char'                                                                 
      

CHECKBUTTON

None
Value:
'checkbutton'                                                          
      

CHORD

None
Value:
'chord'                                                                
      

COMMAND

None
Value:
'command'                                                              
      

CURRENT

None
Value:
'current'                                                              
      

DISABLED

None
Value:
'disabled'                                                             
      

DOTBOX

None
Value:
'dotbox'                                                               
      

E

None
Value:
'e'                                                                    
      

END

None
Value:
'end'                                                                  
      

EW

None
Value:
'ew'                                                                   
      

EXCEPTION

None
Value:
8                                                                     
      

EXTENDED

None
Value:
'extended'                                                             
      

FALSE

None
Value:
0                                                                     
      

FIRST

None
Value:
'first'                                                                
      

FLAT

None
Value:
'flat'                                                                 
      

GROOVE

None
Value:
'groove'                                                               
      

HIDDEN

None
Value:
'hidden'                                                               
      

HORIZONTAL

None
Value:
'horizontal'                                                           
      

INSERT

None
Value:
'insert'                                                               
      

INSIDE

None
Value:
'inside'                                                               
      

LAST

None
Value:
'last'                                                                 
      

LEFT

None
Value:
'left'                                                                 
      

MITER

None
Value:
'miter'                                                                
      

MOVETO

None
Value:
'moveto'                                                               
      

MULTIPLE

None
Value:
'multiple'                                                             
      

N

None
Value:
'n'                                                                    
      

NE

None
Value:
'ne'                                                                   
      

NO

None
Value:
0                                                                     
      

NONE

None
Value:
'none'                                                                 
      

NORMAL

None
Value:
'normal'                                                               
      

NS

None
Value:
'ns'                                                                   
      

NSEW

None
Value:
'nsew'                                                                 
      

NUMERIC

None
Value:
'numeric'                                                              
      

NW

None
Value:
'nw'                                                                   
      

OFF

None
Value:
0                                                                     
      

ON

None
Value:
1                                                                     
      

OUTSIDE

None
Value:
'outside'                                                              
      

PAGES

None
Value:
'pages'                                                                
      

PIESLICE

None
Value:
'pieslice'                                                             
      

PROJECTING

None
Value:
'projecting'                                                           
      

RADIOBUTTON

None
Value:
'radiobutton'                                                          
      

RAISED

None
Value:
'raised'                                                               
      

READABLE

None
Value:
2                                                                     
      

RIDGE

None
Value:
'ridge'                                                                
      

RIGHT

None
Value:
'right'                                                                
      

ROUND

None
Value:
'round'                                                                
      

S

None
Value:
's'                                                                    
      

SCROLL

None
Value:
'scroll'                                                               
      

SE

None
Value:
'se'                                                                   
      

SEL

None
Value:
'sel'                                                                  
      

SEL_FIRST

None
Value:
'sel.first'                                                            
      

SEL_LAST

None
Value:
'sel.last'                                                             
      

SEPARATOR

None
Value:
'separator'                                                            
      

SINGLE

None
Value:
'single'                                                               
      

SOLID

None
Value:
'solid'                                                                
      

SUNKEN

None
Value:
'sunken'                                                               
      

SW

None
Value:
'sw'                                                                   
      

StringTypes

None
Value:
(<type 'str'>, <type 'unicode'>)                                       
      

TOP

None
Value:
'top'                                                                  
      

TRUE

None
Value:
1                                                                     
      

TclVersion

None
Value:
8.4000000000000004                                                    
      

TkVersion

None
Value:
8.4000000000000004                                                    
      

UNDERLINE

None
Value:
'underline'                                                            
      

UNITS

None
Value:
'units'                                                                
      

VERTICAL

None
Value:
'vertical'                                                             
      

W

None
Value:
'w'                                                                    
      

WORD

None
Value:
'word'                                                                 
      

WRITABLE

None
Value:
4                                                                     
      

X

None
Value:
'x'                                                                    
      

Y

None
Value:
'y'                                                                    
      

YES

None
Value:
1                                                                     
      

_MacOS

None
Value:
None                                                                  
      

__version__

None
Value:
'$Revision: 1.181.2.2 $'                                               
      

_default_root

None
Value:
None                                                                  
      

_support_default_root

None
Value:
1                                                                     
      

_varnum

None
Value:
0                                                                     
      

wantobjects

None
Value:
1