Staging: this is not the live site, pydocs.org.
Graphical user interfaces with Tk
The Misc class is a mix-in inherited by Tk and, through BaseWidget, by every widget. It provides the large set of methods common to all Tk objects: querying window information, managing event bindings and the event loop, controlling the keyboard focus and pointer grabs, accessing the selection, clipboard and option database, and assorted utility and introspection services. Because they are inherited, these methods are available on every widget and on the Tk application object, and are documented here once rather than repeated for each widget. Members of Misc a after Schedule the callable func to be called after ms milliseconds, with args and kw passed to it as positional and keyword arguments. after_cancel Cancel a callback previously scheduled with after() or after_idle(). after_idle Schedule the callable func to be called, with args and kw passed to it, when the Tk main loop next becomes idle, that is, when it has no other events to process. after_info If id is omitted, return a tuple of the identifiers of all callbacks currently scheduled with after() and after_idle() for this interpreter. anchor Set the anchor that controls where the grid is placed inside this container when the container is larger than the grid and no row or column has a non-zero weight. b bbox Return the bounding box, in pixels, of a region of the grid laid out in this container, as a 4-tuple (xoffset, yoffset, width, height). bell Ring the bell on the display for this widget, using the display’s current bell-related settings, and reset the screen saver for the screen. bind Bind the event pattern sequence on this widget to the callable func. bind_all Like bind(), but bind func to the special binding tag 'all', so that the binding applies to every widget in the application. bind_class Like bind(), but bind func to the binding tag className rather than to a single widget, so that the binding applies to every widget having that tag. bindtags If tagList is omitted, return a tuple of the binding tags associated with this widget. busy Make this widget appear busy. busy_cget Return the current value of the busy configuration option. busy_config Query or modify the configuration options of the busy window. busy_configure Query or modify the configuration options of the busy window. busy_current Return a list of widgets that are currently busy. busy_forget Make this widget no longer busy, releasing the resources (including the transparent window) allocated when it was made busy. busy_status Return True if the widget is currently busy, False otherwise. c cget Return the current value of the configuration option named key for this widget, as a string. clipboard_append Append string to the Tk clipboard and claim ownership of the clipboard on this widget’s display. clipboard_clear Claim ownership of the clipboard on this widget’s display and remove any previous contents. clipboard_get Retrieve data from the clipboard on this widget’s display. columnconfigure Query or set the properties of the column (or columns) index of the grid managed by this container. config Query or modify the configuration options of the widget. configure Query or modify the configuration options of the widget. content Same as pack_slaves(): return the child widgets managed by this container with the pack geometry manager, in packing order. d deletecommand Delete the Tcl command named name, such as one previously returned by register(). destroy Destroy this widget and all of its descendant widgets, and delete the Tcl commands associated with them. e event_add Associate the virtual event virtual, whose name has the form '<<Paste>>', with each of the physical event patterns given by sequences, so that the virtual event triggers whenever any of them occurs. event_delete Remove each of sequences from those associated with the virtual event virtual. event_generate Generate the event sequence on this widget and arrange for it to be processed just as if it had come from the window system. event_info If virtual is omitted, return a tuple of all the virtual events that are currently defined. f focus Direct the keyboard input focus for this widget’s display to this widget. focus_displayof Return the widget that currently has the keyboard focus on the display where this widget is located, or None if no widget in the application has the focus on that display. focus_force Direct the keyboard input focus to this widget even if the application does not currently have the input focus for the widget’s display. focus_get Return the widget that currently has the keyboard focus in the application, or None if no widget in the application has the focus. focus_lastfor Return the most recent widget to have had the keyboard focus among all the widgets in the same top level as this widget; this is the widget that will receive the focus the next time the window manage… focus_set Direct the keyboard input focus for this widget’s display to this widget. g getboolean Interpret the string s as a Tcl boolean and return the corresponding bool. getdouble Interpret the string s as a Tcl floating-point number and return it as a float. getint Interpret the string s as a Tcl integer and return it as an int. getvar Return the value of the Tcl global variable named name. grab_current Return the widget that currently holds the grab in this application for this widget’s display, or None if there is no such widget. grab_release Release the grab on this widget if there is one; otherwise do nothing. grab_set Set a local grab on this widget. grab_status Return None if no grab is currently set on this widget, "local" if a local grab is set, or "global" if a global grab is set. grid_anchor Set the anchor that controls where the grid is placed inside this container when the container is larger than the grid and no row or column has a non-zero weight. grid_bbox Return the bounding box, in pixels, of a region of the grid laid out in this container, as a 4-tuple (xoffset, yoffset, width, height). grid_columnconfigure Query or set the properties of the column (or columns) index of the grid managed by this container. grid_content Same as grid_slaves(): return the child widgets managed in this container’s grid, optionally restricted to a given row or column. grid_location Return the (column, row) of the grid cell that contains the pixel at position (x, y), given in pixels relative to this container. grid_propagate Enable or disable geometry propagation for this container when it manages its children with the grid geometry manager. grid_rowconfigure Query or set the properties of the row (or rows) index of the grid managed by this container. grid_size Return the size of the grid managed by this container as a (columns, rows) tuple. grid_slaves Return a list of the child widgets managed in this container’s grid, most recently managed first. i image_names Return the names of all images that currently exist in the Tcl interpreter. image_types Return the available image types, such as 'photo' and 'bitmap'. info_patchlevel Return the Tcl/Tk patch level as a named tuple with the same five fields as sys.version_info: major, minor, micro, releaselevel and serial. k keys Return a list of the names of all configuration options of this widget. l lift Raise this widget in the stacking order so that it is drawn on top of its siblings. lower Lower this widget in the stacking order so that it is drawn beneath its siblings. m mainloop Enter the Tk event loop, which processes events until all windows are destroyed. n nametowidget Return the widget instance corresponding to the Tk pathname name. o option_add Add an option to the Tk option database that associates value with pattern. option_get Return the value of the option matching this widget under name and className from the Tk option database, or an empty string if there is no matching entry. option_readfile Read the file named fileName, which should have the standard format for an X resource database such as .Xdefaults, and add all the options it specifies to the Tk option database. p pack_content Same as pack_slaves(): return the child widgets managed by this container with the pack geometry manager, in packing order. pack_propagate Enable or disable geometry propagation for this container when it manages its children with the pack geometry manager. pack_slaves Return a list of the child widgets managed by this container with the pack geometry manager, in packing order. place_content Same as place_slaves(): return the child widgets managed by this container with the place geometry manager. place_slaves Return a list of the child widgets managed by this container with the place geometry manager. propagate Enable or disable geometry propagation for this container when it manages its children with the pack geometry manager. q quit Quit the Tcl interpreter, causing mainloop() to return. r register Register the Python callable func as a Tcl command and return the name of the new command as a string. rowconfigure Query or set the properties of the row (or rows) index of the grid managed by this container. s selection_handle Register command as a handler to supply the X selection owned by this widget when another application requests it. selection_own Make this widget the owner of the X selection on its display. selection_own_get Return the widget in this application that owns the X selection on the display containing this widget, or None if no widget in this application owns the selection. send Send the Tcl command cmd, with the given args, to the Tcl interpreter registered under the name interp, and return its result. setvar Set the Tcl global variable named name to value. size Return the size of the grid managed by this container as a (columns, rows) tuple. slaves Return a list of the child widgets managed by this container with the pack geometry manager, in packing order. t tk_bisque Restore the application’s colors to the light brown (bisque) color scheme used in Tk 3.6 and earlier versions. tk_busy Make this widget appear busy. tk_busy_cget Return the current value of the busy configuration option. tk_busy_config Query or modify the configuration options of the busy window. tk_busy_forget Make this widget no longer busy, releasing the resources (including the transparent window) allocated when it was made busy. tk_busy_status Return True if the widget is currently busy, False otherwise. tk_focusFollowsMouse Reconfigure Tk to use an implicit focus model in which the focus is set to a widget whenever the mouse pointer enters it. tk_focusNext Return the next widget after this one in the keyboard traversal order, or None if there is none. tk_focusPrev Return the previous widget before this one in the keyboard traversal order, or None if there is none. tk_strictMotif Query or set whether Tk’s look and feel should strictly adhere to Motif. tkraise Raise this widget in the stacking order so that it is drawn on top of its siblings. u unbind Remove bindings for the event pattern sequence on this widget. unbind_all Remove all bindings for the event pattern sequence from the special binding tag 'all'. unbind_class Remove all bindings for the event pattern sequence from the binding tag className. update Enter the event loop until all pending events, including idle callbacks, have been processed. update_idletasks Enter the event loop until all pending idle callbacks have been called. w wait_variable Wait until the Tcl variable name is modified, continuing to process events in the meantime so that the application stays responsive. wait_visibility Wait until the visibility state of window changes, for example when it first appears on the screen, continuing to process events in the meantime. wait_window Wait until window is destroyed, continuing to process events in the meantime. waitvar Wait until the Tcl variable name is modified, continuing to process events in the meantime so that the application stays responsive. winfo_atom Return the integer identifier for the atom whose name is name, creating a new atom if none exists. winfo_atomname Return the textual name for the atom whose integer identifier is id. winfo_cells Return the number of cells in the colormap for the widget. winfo_children Return a list containing the widgets that are children of the widget, in stacking order from lowest to highest. winfo_colormapfull Return True if the colormap for the widget is known to be full, False otherwise. winfo_containing Return the widget containing the point given by rootX and rootY, or None if no window in this application contains the point. winfo_depth Return the depth of the widget, that is, the number of bits per pixel. winfo_exists Return true if the widget exists, false otherwise. winfo_fpixels Return a floating-point value giving the number of pixels in the widget corresponding to the screen distance number (for example, "2.0c" or "1i"). winfo_geometry Return the geometry of the widget, in the form widthxheight+x+y. winfo_id Return a low-level platform-specific identifier for the widget. winfo_interps Return a tuple of the names of all Tcl interpreters currently registered for a particular display. winfo_ismapped Return true if the widget is currently mapped, false otherwise. winfo_manager Return the name of the geometry manager currently responsible for the widget, or an empty string if it is not managed by any geometry manager. winfo_name Return the widget’s name within its parent, as opposed to its full path name. winfo_parent Return the path name of the widget’s parent, or an empty string if the widget is the main window of the application. winfo_pathname Return the path name of the window whose identifier is id. winfo_pixels Return the number of pixels in the widget corresponding to the screen distance number (for example, "2.0c" or "1i"). winfo_pointerx Return the pointer’s x coordinate, in pixels, relative to the screen’s root window (or virtual root, if one is in use). winfo_pointerxy Return the pointer’s coordinates as an (x, y) tuple, in pixels, relative to the screen’s root window (or virtual root, if one is in use). winfo_pointery Return the pointer’s y coordinate, in pixels, relative to the screen’s root window (or virtual root, if one is in use). winfo_rgb Return an (r, g, b) tuple of the red, green, and blue intensities, in the range 0 to 65535, that correspond to color in the widget. winfo_rootx Return the x coordinate, in the root window of the screen, of the upper-left corner of the widget’s border (or of the widget itself if it has no border). winfo_rooty Return the y coordinate, in the root window of the screen, of the upper-left corner of the widget’s border (or of the widget itself if it has no border). winfo_screen Return the name of the screen associated with the widget, in the form displayName.screenIndex. winfo_screencells Return the number of cells in the default colormap for the widget’s screen. winfo_screendepth Return the depth of the root window of the widget’s screen, that is, the number of bits per pixel. winfo_screenvisual Return the default visual class for the widget’s screen, one of "directcolor", "grayscale", "pseudocolor", "staticcolor", "staticgray", or "truecolor". winfo_server Return a string containing information about the server for the widget’s display. winfo_toplevel Return the top-of-hierarchy window containing the widget. winfo_viewable Return true if the widget and all of its ancestors up through the nearest toplevel window are mapped, false otherwise. winfo_visual Return the visual class for the widget, one of "directcolor", "grayscale", "pseudocolor", "staticcolor", "staticgray", or "truecolor". winfo_vrootheight Return the height of the virtual root window associated with the widget if there is one; otherwise return the height of the widget’s screen. winfo_vrootwidth Return the width of the virtual root window associated with the widget if there is one; otherwise return the width of the widget’s screen. winfo_vrootx Return the x offset of the virtual root window associated with the widget, relative to the root window of its screen. winfo_vrooty Return the y offset of the virtual root window associated with the widget, relative to the root window of its screen. winfo_x Return the x coordinate, in the widget’s parent, of the upper-left corner of the widget’s border (or of the widget itself if it has no border). winfo_y Return the y coordinate, in the widget’s parent, of the upper-left corner of the widget’s border (or of the widget itself if it has no border).
Python docs © Python Software Foundation · Examples CC0 ·
Source on GitHub · Not affiliated with the PSF