An Introduction to Tkinter
前页 | Chapter 43. The Toplevel Widget | 后页

# Options

Table 43-1.

Option | Type | Description
--- | --- | ---
`height, width` | distance | Toplevel window size.
`background (bg)` | color | The background color to use in this toplevel. This defaults to the application background color. To prevent updates, set the color to an empty string.
`colormap` | widget | Some displays support only 256 colors (some use even less). Such displays usually provide a color map to specify which 256 colors to use. This option allows you to specify which color map to use for this toplevel window, and its child widgets.

By default, a new toplevel window uses the same color map as the root window. Using this option, you can reuse the color map of another window instead (this window must be on the same screen and have the same visual characteristics). You can also use the value "new" to allocate a new color map for this window.

You cannot change this option once you've created the window.

`menu` | widget | A menu to associate with this toplevel window. On Unix and Windows, the menu is placed at the top of the toplevel window itself. On Macs, the menu is displayed at the top of the screen when the toplevel window is selected.
`cursor` | cursor | The cursor to show when the mouse pointer is placed over the toplevel widget. Default is a system specific arrow cursor.
`relief` | constant | Border decoration: either FLAT, SUNKEN, RAISED, GROOVE, or RIDGE. The default is FLAT.
`borderwidth (bd)` | distance | Width of the 3D border. Defaults to 0 (no border).
`takefocus` | flag | Indicates that the user can use the Tab key to move to this widget. Default is an empty string, which means that the toplevel accepts focus only if it has any keyboard bindings (default is off, in other words).
`highlightbackground, highlightcolor` | color | Controls how to draw the focus highlight border. When any child to the toplevel window has focus, the border is drawn in the highlightcolor color. Otherwise, it is drawn in the highlightbackground color. The defaults are system specific.
`highlightthickness` | distance | Controls the width of the focus highlight border. Default is 0 (no border).
`class (class_)` | class |
`visual` | visual | Controls the "visual" type to use for this window. This option should usually be omitted. In that case, the visual type is inherited from the root window. Some more advanced displays support "mixed visuals". This typically means that the root window is a 256-color display (the "pseudocolor" visual type), but that individual windows can be displayed as true 24-bit color (the "truecolor" visual type). On such displays, you may wish to explicitly set the visual option to "truecolor" for any windows used to display full-color images.

Other possible values include "directcolor", "staticcolor", "grayscale", or "staticgray". See your X window documentation for details.

You cannot change this option once you've created the window.

`screen` | screen |
`container` | container |
`use` | widget |

前页 | Home | 后页
Methods | Up | Basic Widget Methods