Tkinter.Tk¶
-
class
Tkinter.Tk(screenName=None, baseName=None, className='Tk', useTk=1, sync=0, use=None)[source]¶ Toplevel widget of Tk which represents mostly the main window of an application. It has an associated Tcl interpreter.
Methods¶
_Misc__winfo_getint(x) |
Internal function. |
_Misc__winfo_parseitem(t) |
Internal function. |
__contains__(key) |
|
__getattr__(attr) |
Delegate attribute access to the interpreter object |
__getitem__(key) |
Return the resource value for a KEY given as string. |
__init__([screenName, baseName, className, ...]) |
Return a new Toplevel widget on screen SCREENNAME. |
__setitem__(key, value) |
|
__str__() |
Return the window path name of this widget. |
_bind(what, sequence, func, add[, needcleanup]) |
Internal function. |
_configure(cmd, cnf, kw) |
Internal function. |
_displayof(displayof) |
Internal function. |
_getboolean(string) |
Internal function. |
_getconfigure(*args) |
Call Tcl configure command and return the result as a dict. |
_getconfigure1(*args) |
|
_getdoubles(string) |
Internal function. |
_getints(string) |
Internal function. |
_grid_configure(command, index, cnf, kw) |
Internal function. |
_gridconvvalue(value) |
|
_loadtk() |
|
_nametowidget(name) |
Return the Tkinter instance of a widget identified by its Tcl name NAME. |
_options(cnf[, kw]) |
Internal function. |
_register(func[, subst, needcleanup]) |
Return a newly created Tcl function. |
_report_exception() |
Internal function. |
_root() |
Internal function. |
_substitute(*args) |
Internal function. |
after(ms[, func]) |
Call function once after given time. |
after_cancel(id) |
Cancel scheduling of function identified with ID. |
after_idle(func, *args) |
Call FUNC once if the Tcl main loop has no event to process. |
aspect([minNumer, minDenom, maxNumer, maxDenom]) |
Instruct the window manager to set the aspect ratio (width/height) of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. |
attributes(*args) |
This subcommand returns or sets platform specific attributes |
bbox([column, row, col2, row2]) |
Return a tuple of integer coordinates for the bounding box of this widget controlled by the geometry manager grid. |
bell([displayof]) |
Ring a display’s bell. |
bind([sequence, func, add]) |
Bind to this widget at event SEQUENCE a call to function FUNC. |
bind_all([sequence, func, add]) |
Bind to all widgets at an event SEQUENCE a call to function FUNC. |
bind_class(className[, sequence, func, add]) |
Bind to widgets with bindtag CLASSNAME at event SEQUENCE a call of function FUNC. |
bindtags([tagList]) |
Set or get the list of bindtags for this widget. |
cget(key) |
Return the resource value for a KEY given as string. |
client([name]) |
Store NAME in WM_CLIENT_MACHINE property of this widget. |
clipboard_append(string, **kw) |
Append STRING to the Tk clipboard. |
clipboard_clear(**kw) |
Clear the data in the Tk clipboard. |
clipboard_get(**kw) |
Retrieve data from the clipboard on window’s display. |
colormapwindows(*wlist) |
Store list of window names (WLIST) into WM_COLORMAPWINDOWS property of this widget. |
colormodel([value]) |
Useless. |
columnconfigure(index[, cnf]) |
Configure column INDEX of a grid. |
command([value]) |
Store VALUE in WM_COMMAND property. |
config([cnf]) |
Configure resources of a widget. |
configure([cnf]) |
Configure resources of a widget. |
deiconify() |
Deiconify this widget. |
deletecommand(name) |
Internal function. |
destroy() |
Destroy this and all descendants widgets. |
event_add(virtual, *sequences) |
Bind a virtual event VIRTUAL (of the form <<Name>>) to an event SEQUENCE such that the virtual event is triggered whenever SEQUENCE occurs. |
event_delete(virtual, *sequences) |
Unbind a virtual event VIRTUAL from SEQUENCE. |
event_generate(sequence, **kw) |
Generate an event SEQUENCE. |
event_info([virtual]) |
Return a list of all virtual events or the information about the SEQUENCE bound to the virtual event VIRTUAL. |
focus() |
Direct input focus to this widget. |
focus_displayof() |
Return the widget which has currently the focus on the display where this widget is located. |
focus_force() |
Direct input focus to this widget even if the application does not have the focus. |
focus_get() |
Return the widget which has currently the focus in the application. |
focus_lastfor() |
Return the widget which would have the focus if top level for this widget gets the focus from the window manager. |
focus_set() |
Direct input focus to this widget. |
focusmodel([model]) |
Set focus model to MODEL. |
frame() |
Return identifier for decorative frame of this widget if present. |
geometry([newGeometry]) |
Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. |
getboolean(s) |
Return a boolean value for Tcl boolean values true and false given as parameter. |
getvar([name]) |
Return value of Tcl variable NAME. |
grab_current() |
Return widget which has currently the grab in this application or None. |
grab_release() |
Release grab for this widget if currently set. |
grab_set() |
Set grab for this widget. |
grab_set_global() |
Set global grab for this widget. |
grab_status() |
Return None, “local” or “global” if this widget has no, a local or a global grab. |
grid([baseWidth, baseHeight, widthInc, ...]) |
Instruct the window manager that this widget shall only be resized on grid boundaries. |
grid_bbox([column, row, col2, row2]) |
Return a tuple of integer coordinates for the bounding box of this widget controlled by the geometry manager grid. |
grid_columnconfigure(index[, cnf]) |
Configure column INDEX of a grid. |
grid_location(x, y) |
Return a tuple of column and row which identify the cell at which the pixel at position X and Y inside the master widget is located. |
grid_propagate([flag]) |
Set or get the status for propagation of geometry information. |
grid_rowconfigure(index[, cnf]) |
Configure row INDEX of a grid. |
grid_size() |
Return a tuple of the number of column and rows in the grid. |
grid_slaves([row, column]) |
Return a list of all slaves of this widget in its packing order. |
group([pathName]) |
Set the group leader widgets for related widgets to PATHNAME. |
iconbitmap([bitmap, default]) |
Set bitmap for the iconified widget to BITMAP. |
iconify() |
Display widget as icon. |
iconmask([bitmap]) |
Set mask for the icon bitmap of this widget. |
iconname([newName]) |
Set the name of the icon for this widget. |
iconposition([x, y]) |
Set the position of the icon of this widget to X and Y. |
iconwindow([pathName]) |
Set widget PATHNAME to be displayed instead of icon. |
image_names() |
Return a list of all existing image names. |
image_types() |
Return a list of all available image types (e.g. |
keys() |
Return a list of all resource names of this widget. |
lift([aboveThis]) |
Raise this widget in the stacking order. |
loadtk() |
|
lower([belowThis]) |
Lower this widget in the stacking order. |
mainloop([n]) |
Call the mainloop of Tk. |
maxsize([width, height]) |
Set max WIDTH and HEIGHT for this widget. |
minsize([width, height]) |
Set min WIDTH and HEIGHT for this widget. |
nametowidget(name) |
Return the Tkinter instance of a widget identified by its Tcl name NAME. |
option_add(pattern, value[, priority]) |
Set a VALUE (second parameter) for an option PATTERN (first parameter). |
option_clear() |
Clear the option database. |
option_get(name, className) |
Return the value for an option NAME for this widget with CLASSNAME. |
option_readfile(fileName[, priority]) |
Read file FILENAME into the option database. |
overrideredirect([boolean]) |
Instruct the window manager to ignore this widget if BOOLEAN is given with 1. |
pack_propagate([flag]) |
Set or get the status for propagation of geometry information. |
pack_slaves() |
Return a list of all slaves of this widget in its packing order. |
place_slaves() |
Return a list of all slaves of this widget in its packing order. |
positionfrom([who]) |
Instruct the window manager that the position of this widget shall be defined by the user if WHO is “user”, and by its own policy if WHO is “program”. |
propagate([flag]) |
Set or get the status for propagation of geometry information. |
protocol([name, func]) |
Bind function FUNC to command NAME for this widget. |
quit() |
Quit the Tcl interpreter. |
readprofile(baseName, className) |
Internal function. |
register(func[, subst, needcleanup]) |
Return a newly created Tcl function. |
report_callback_exception(exc, val, tb) |
Report callback exception on sys.stderr. |
resizable([width, height]) |
Instruct the window manager whether this width can be resized in WIDTH or HEIGHT. |
rowconfigure(index[, cnf]) |
Configure row INDEX of a grid. |
selection_clear(**kw) |
Clear the current X selection. |
selection_get(**kw) |
Return the contents of the current X selection. |
selection_handle(command, **kw) |
Specify a function COMMAND to call if the X selection owned by this widget is queried by another application. |
selection_own(**kw) |
Become owner of X selection. |
selection_own_get(**kw) |
Return owner of X selection. |
send(interp, cmd, *args) |
Send Tcl command CMD to different interpreter INTERP to be executed. |
setvar([name, value]) |
Set Tcl variable NAME to VALUE. |
size() |
Return a tuple of the number of column and rows in the grid. |
sizefrom([who]) |
Instruct the window manager that the size of this widget shall be defined by the user if WHO is “user”, and by its own policy if WHO is “program”. |
slaves() |
Return a list of all slaves of this widget in its packing order. |
state([newstate]) |
Query or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only). |
title([string]) |
Set the title of this widget. |
tk_bisque() |
Change the color scheme to light brown as used in Tk 3.6 and before. |
tk_focusFollowsMouse() |
The widget under mouse will get automatically focus. |
tk_focusNext() |
Return the next widget in the focus order which follows widget which has currently the focus. |
tk_focusPrev() |
Return previous widget in the focus order. |
tk_menuBar(*args) |
Do not use. |
tk_setPalette(*args, **kw) |
Set a new color scheme for all widget elements. |
tk_strictMotif([boolean]) |
Set Tcl internal variable, whether the look and feel should adhere to Motif. |
tkraise([aboveThis]) |
Raise this widget in the stacking order. |
transient([master]) |
Instruct the window manager that this widget is transient with regard to widget MASTER. |
unbind(sequence[, funcid]) |
Unbind for this widget for event SEQUENCE the function identified with FUNCID. |
unbind_all(sequence) |
Unbind for all widgets for event SEQUENCE all functions. |
unbind_class(className, sequence) |
Unbind for all widgets with bindtag CLASSNAME for event SEQUENCE all functions. |
update() |
Enter event loop until all pending events have been processed by Tcl. |
update_idletasks() |
Enter event loop until all idle callbacks have been called. |
wait_variable([name]) |
Wait until the variable is modified. |
wait_visibility([window]) |
Wait until the visibility of a WIDGET changes (e.g. |
wait_window([window]) |
Wait until a WIDGET is destroyed. |
waitvar([name]) |
Wait until the variable is modified. |
winfo_atom(name[, displayof]) |
Return integer which represents atom NAME. |
winfo_atomname(id[, displayof]) |
Return name of atom with identifier ID. |
winfo_cells() |
Return number of cells in the colormap for this widget. |
winfo_children() |
Return a list of all widgets which are children of this widget. |
winfo_class() |
Return window class name of this widget. |
winfo_colormapfull() |
Return true if at the last color request the colormap was full. |
winfo_containing(rootX, rootY[, displayof]) |
Return the widget which is at the root coordinates ROOTX, ROOTY. |
winfo_depth() |
Return the number of bits per pixel. |
winfo_exists() |
Return true if this widget exists. |
winfo_fpixels(number) |
Return the number of pixels for the given distance NUMBER (e.g. |
winfo_geometry() |
Return geometry string for this widget in the form “widthxheight+X+Y”. |
winfo_height() |
Return height of this widget. |
winfo_id() |
Return identifier ID for this widget. |
winfo_interps([displayof]) |
Return the name of all Tcl interpreters for this display. |
winfo_ismapped() |
Return true if this widget is mapped. |
winfo_manager() |
Return the window mananger name for this widget. |
winfo_name() |
Return the name of this widget. |
winfo_parent() |
Return the name of the parent of this widget. |
winfo_pathname(id[, displayof]) |
Return the pathname of the widget given by ID. |
winfo_pixels(number) |
Rounded integer value of winfo_fpixels. |
winfo_pointerx() |
Return the x coordinate of the pointer on the root window. |
winfo_pointerxy() |
Return a tuple of x and y coordinates of the pointer on the root window. |
winfo_pointery() |
Return the y coordinate of the pointer on the root window. |
winfo_reqheight() |
Return requested height of this widget. |
winfo_reqwidth() |
Return requested width of this widget. |
winfo_rgb(color) |
Return tuple of decimal values for red, green, blue for COLOR in this widget. |
winfo_rootx() |
Return x coordinate of upper left corner of this widget on the root window. |
winfo_rooty() |
Return y coordinate of upper left corner of this widget on the root window. |
winfo_screen() |
Return the screen name of this widget. |
winfo_screencells() |
Return the number of the cells in the colormap of the screen of this widget. |
winfo_screendepth() |
Return the number of bits per pixel of the root window of the screen of this widget. |
winfo_screenheight() |
Return the number of pixels of the height of the screen of this widget in pixel. |
winfo_screenmmheight() |
Return the number of pixels of the height of the screen of this widget in mm. |
winfo_screenmmwidth() |
Return the number of pixels of the width of the screen of this widget in mm. |
winfo_screenvisual() |
Return one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the default colormodel of this screen. |
winfo_screenwidth() |
Return the number of pixels of the width of the screen of this widget in pixel. |
winfo_server() |
Return information of the X-Server of the screen of this widget in the form “XmajorRminor vendor vendorVersion”. |
winfo_toplevel() |
Return the toplevel widget of this widget. |
winfo_viewable() |
Return true if the widget and all its higher ancestors are mapped. |
winfo_visual() |
Return one of the strings directcolor, grayscale, pseudocolor, staticcolor, staticgray, or truecolor for the colormodel of this widget. |
winfo_visualid() |
Return the X identifier for the visual for this widget. |
winfo_visualsavailable([includeids]) |
Return a list of all visuals available for the screen of this widget. |
winfo_vrootheight() |
Return the height of the virtual root window associated with this widget in pixels. |
winfo_vrootwidth() |
Return the width of the virtual root window associated with this widget in pixel. |
winfo_vrootx() |
Return the x offset of the virtual root relative to the root window of the screen of this widget. |
winfo_vrooty() |
Return the y offset of the virtual root relative to the root window of the screen of this widget. |
winfo_width() |
Return the width of this widget. |
winfo_x() |
Return the x coordinate of the upper left corner of this widget in the parent. |
winfo_y() |
Return the y coordinate of the upper left corner of this widget in the parent. |
withdraw() |
Withdraw this widget from the screen such that it is unmapped and forgotten by the window manager. |
wm_aspect([minNumer, minDenom, maxNumer, ...]) |
Instruct the window manager to set the aspect ratio (width/height) of this widget to be between MINNUMER/MINDENOM and MAXNUMER/MAXDENOM. |
wm_attributes(*args) |
This subcommand returns or sets platform specific attributes |
wm_client([name]) |
Store NAME in WM_CLIENT_MACHINE property of this widget. |
wm_colormapwindows(*wlist) |
Store list of window names (WLIST) into WM_COLORMAPWINDOWS property of this widget. |
wm_command([value]) |
Store VALUE in WM_COMMAND property. |
wm_deiconify() |
Deiconify this widget. |
wm_focusmodel([model]) |
Set focus model to MODEL. |
wm_frame() |
Return identifier for decorative frame of this widget if present. |
wm_geometry([newGeometry]) |
Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. |
wm_grid([baseWidth, baseHeight, widthInc, ...]) |
Instruct the window manager that this widget shall only be resized on grid boundaries. |
wm_group([pathName]) |
Set the group leader widgets for related widgets to PATHNAME. |
wm_iconbitmap([bitmap, default]) |
Set bitmap for the iconified widget to BITMAP. |
wm_iconify() |
Display widget as icon. |
wm_iconmask([bitmap]) |
Set mask for the icon bitmap of this widget. |
wm_iconname([newName]) |
Set the name of the icon for this widget. |
wm_iconposition([x, y]) |
Set the position of the icon of this widget to X and Y. |
wm_iconwindow([pathName]) |
Set widget PATHNAME to be displayed instead of icon. |
wm_maxsize([width, height]) |
Set max WIDTH and HEIGHT for this widget. |
wm_minsize([width, height]) |
Set min WIDTH and HEIGHT for this widget. |
wm_overrideredirect([boolean]) |
Instruct the window manager to ignore this widget if BOOLEAN is given with 1. |
wm_positionfrom([who]) |
Instruct the window manager that the position of this widget shall be defined by the user if WHO is “user”, and by its own policy if WHO is “program”. |
wm_protocol([name, func]) |
Bind function FUNC to command NAME for this widget. |
wm_resizable([width, height]) |
Instruct the window manager whether this width can be resized in WIDTH or HEIGHT. |
wm_sizefrom([who]) |
Instruct the window manager that the size of this widget shall be defined by the user if WHO is “user”, and by its own policy if WHO is “program”. |
wm_state([newstate]) |
Query or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only). |
wm_title([string]) |
Set the title of this widget. |
wm_transient([master]) |
Instruct the window manager that this widget is transient with regard to widget MASTER. |
wm_withdraw() |
Withdraw this widget from the screen such that it is unmapped and forgotten by the window manager. |