pythonware.com products ::: library ::: search ::: daily Python-URL!

Library

An Introduction to Tkinter

Window Related Information :::

A Django site.
   

Window Related Information

Back   Next   

 Window Related Information

This group of methods provide information related to the widget (self) to which the method belongs.

  winfo_cells

winfo_cells(). Return the number of "cells" in the color map for self. This is typically a value between 2 and 256 (also for true color displays, by some odd reason).

  winfo_children

winfo_children(). Return a list containing widget instances for all children of self. The windows are returned in stacking order from bottom to top. If the order doesn't matter, you can get the same information from the children widget attribute (it's a dictionary mapping Tk widget names to widget instances, so widget.children.values() gives you a list of instances).

  winfo_class

winfo_class(). Returns the Tkinter widget class name for self. If self is a Tkinter base widget, widget.winfo_class() is the same as widget.__class__.__name__.

  winfo_colormapfull

winfo_colormapfull(). Return true if the color map for self is full.

  winfo_containing

winfo_containing(x, y). Return the widget at the given position, or None if there is no such window, or it isn't owned by this application. The coordinates are given relative to the screen's upper left corner.

  winfo_depth

winfo_depth(). Return the bit depth used to display self. This is typically 8 for a 256-color display device, 15 or 16 for a "hicolor" display, and 24 or 32 for a true color display.

  winfo_exists

winfo_exists(). Return true if there is Tk window corresponding to self. Unless you've done something really strange, this method should always return true.

  winfo_pixels

winfo_pixels(distance), winfo_fpixels(distance). Convert the given distance (in any form accepted by Tkinter) to the corresponding number of pixels. winfo_pixels returns an integer value, winfo_fpixels a floating point value.

  winfo_geometry

winfo_geometry(). Returns a string describing self's "geometry". The string has the following format:

    "%dx%d%+d%+d" % (width, height, xoffset, yoffset)

where all coordinates are given in pixels.

 winfo_width, winfo_height

winfo_width(), winfo_height(). Return the width (height) of self, in pixels. Note that if the window isn't managed by a geometry manager, these methods returns 1. To you get the real value, you may have to call update_idletasks first. You can also use winfo_reqheight to get the widget's requested height (that is, the "natural" size as defined by the widget itself based on it's contents).

 winfo_id

winfo_id(). Return a string containing a system-specific window identifier corresponding to self. For Unix, this is the X window identifier. For Windows, this is the HWND cast to a long integer.

  winfo_ismapped

winfo_ismapped(). Return true if there is window corresponding to self in the underlying window system (an X window, a Windows HWND, etc).

  winfo_manager

winfo_manager(). Return the name of the geometry manager used to keep manage self (typically one of grid, pack, place, canvas, or text).

FIXME: this is not implemented by Tkinter (or is it, in 1.5.2?)

  winfo_name

winfo_name(). Return the Tk widget name. This is the same as the last part of the full widget name (which you can get via str(widget)).

  winfo_parent

winfo_parent(). Return the full widget name of self's parent, or an empty string if self doesn't have a parent (if self is the root window, that is).

To get the widget instance instead, you can simply use the master attribute instead of calling this method (the master attribute is None for the root window). Or if you insist, use _nametowidget to map the full widget name to an instance.

  winfo_pathname

winfo_pathname(id). Return the full window name for the window having the given identity (see winfo_id for details). If the window doesn't exist, or it isn't owned by this application, Tkinter raises a TclError exception.

To convert the full name to a widget instance, use _nametowidget.

 winfo_reqheight, winfo_reqwidth

winfo_reqheight(), winfo_reqwidth(). Return the "natural" height (width) for self. The natural size is the minimal size needed to display the widget's contents, including padding, borders, etc. This size is calculated by the widget itself, based on the given options. The actual widget size is then determined by the widget's geometry manager, based on this value, the size of the widget's master, and the options given to the geometry manager.

 winfo_rootx, winfo_rooty

winfo_rootx(), winfo_rooty(). Return the pixel coordinates for self's upper left corner, relative to the screen's upper left corner.

  winfo_screen

winfo_screen(). Return the X window screen name for the current window. The string has the following format:

    ":%d.%d" % (display, screen)

On Windows and Macintosh, this is always ":0.0".

  winfo_screencells

winfo_screencells(). Returns the number of "cells" in the default color map for self's screen.

  winfo_screendepth

winfo_screendepth(). Return the default bit depth for self's screen.

 winfo_screenwidth, winfo_screenheight

winfo_screenwidth(), winfo_screenheight(). Return the width (height) of self's screen, in pixels.

  winfo_screenmmwidth, winfo_screenmmheight

winfo_screenmmwidth(), winfo_screenmmheight(). Return the width (height) of self's screen, in millimetres. This may not be accurate on all platforms.

FIXME: does this take the logical resolution into account on Windows?

  winfo_screenvisual

winfo_screenvisual(). Return the "visual" type used for self. This is typically "pseudocolor" (for 256-color displays) or "truecolor" (for 16- or 24-bit displays).

Other possible values (on X window systems only) include "directcolor", "staticcolor", "grayscale", or "staticgray".

  winfo_toplevel

winfo_toplevel(). Return the toplevel window (or root) window for self, as a widget instance.

  winfo_visual

winfo_visual(). Return a string describing the display type (the X window "visual") for self's screen. This is one of staticgray, grayscale, staticcolor, psuedocolor, directcolor, or truecolor. For most display devices, this is either psuedocolor (an 8-bit colormapped display), or truecolor (a 15- or 24-bit truecolor display).

 winfo_x, winfo_y

winfo_x(), winfo_y(). Return the pixel coordinates for self's upper left corner, relative to its parent's upper left corner.

Back   Next