Next / Previous / Contents / Shipman's homepage

33. ttk.Frame

Like the Tkinter Frame widget, the ttk.Frame widget is a rectangular container for other widgets. To create a Frame widget as the child of a given parent widget:

    w = ttk.Frame(parent, option=value, ...)

Options include:

Table 42. ttk.Frame options

borderwidth Use this option to specify the width of the border element; the default is zero.
class_ You may provide a widget class name when you create this widget. This name may be used to customize the widget's appearance; see Section 27, “Standardizing appearance”. Once the widget is created, the widget class name cannot be changed.
cursor Use this option to specify the appearance of the mouse cursor when it is over the widget; see Section 5.8, “Cursors”. The default value (an empty string) specifies that the cursor is inherited from the parent widget.
height This option is a dimension that sets the height of the frame. If you want to force the frame to have a specific height, call the .grid_propagate(0) on the widget; see Section 4.2, “Other grid management methods”.
padding To create an empty area inside the frame and outside of the contained widgets, set this option to the desired dimension. For example, padding='0.5i' would clear a half-inch-wide area inside the frame and around the outside of the widgets inside it.
relief Specifies the relief style for the border; see Section 5.6, “Relief styles”. This has no effect unless you also increase the borderwidth.
style Use this option to specify a custom widget style name; see Section 47, “Customizing and creating ttk themes and styles”.
takefocus

Use this option to specify whether a widget is visited during focus traversal; see Section 53, “Focus: routing keyboard input”. Specify takefocus=True if you want the visit to accept focus; specify takefocus=False if the widget is not to accept focus. The default value is an empty string; by default, ttk.Frame widgets do not get focus.

width This option is a dimension that sets the width of the frame. If you want to force the frame to have a specific width, call the .grid_propagate(0) on the widget; see Section 4.2, “Other grid management methods”.

These options on the Tkinter Frame widget are not available as options on the ttk.Frame constructor:

Table 43. Tkinter Frame options not in ttk.Frame

background or bg Configure this option with a style; see Section 47, “Customizing and creating ttk themes and styles”.
highlightbackground To control the color of the focus highlight when the frame does not have focus, use a style map to control the highlightcolor option; see Section 50.2, “ttk style maps: dynamic appearance changes”.
highlightcolor You may specify the default focus highlight color by setting this option in a style. You may also control the focus highlight color using a style map.
highlightthickness Configure this option using a style. This option may not work in all themes.
padx Not supported.
pady Not supported.