Tk - Frame Widget


Advertisements

The frame widget is a rectangular container widget that groups widgets for designing GUI. The syntax for frame widget is shown below −

frame frameName options

Options

The options available for the frame widget are listed below in table −

Sr.No. Syntax & Description
1

-background color

Used to set background color for widget.

2

-borderwidth width

Used to draw with border in 3D effects.

3

-height number

Used to set height for widget.

4

-padx number

Sets the padx for the widget.

5

-pady number

Sets the pady for the widget.

6

-relief condition

Sets the 3D relief for this widget. The condition may be raised, sunken, flat, ridge, solid, or groove.

7

-width number

Sets the width for widget.

A simple example for frame widget is shown below −

#!/usr/bin/wish

frame .myFrame1 -background red  -relief ridge -borderwidth 8 -padx 10 -pady 10
   -height 100 -width 100
frame .myFrame2 -background blue  -relief ridge -borderwidth 8 -padx 10 -pady 10
   -height 100 -width 50
pack .myFrame1 
pack .myFrame2

When we run the above program, we will get the following output −

Frame Widget Example
tk_layout_widgets.htm
Advertisements