Tk - Top Level Widgets


Advertisements

Top level widget is used to create a frame that is a new top level window. The syntax for top level widget is shown below −

toplevel topLevelName options

Options

The options available for the top level 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 top level widget is shown below −

#!/usr/bin/wish

toplevel .top -width 400 -height 100 -background red -relief ridge
   -borderwidth 8 -padx 10 -pady 10 

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

Top Level Example
tk_basic_widgets.htm
Advertisements