Tk - Place Widget


Advertisements

The place widget is used to locate a widget at an absolute location or a relative location based on the size of the window. The syntax for place widget is shown below −

place placeName options

Options

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

Sr.No. Syntax & Description
1

-x xLocation

Sets the absolute x position for widget.

2

-y yLocation

Sets the absolute y position for widget.

3

-relx xFraction

Sets the relative x position as fraction of width for widget.

4

-rely yFraction

Sets the relative y position as fraction of height for widget.

A simple example for place widget is shown below −

#!/usr/bin/wish

 . configure -width 250 -height 300
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
place .myFrame1 -x 0 -y 20
place .myFrame2 -x 50 -y 150

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

Place Example
tk_layout_widgets.htm
Advertisements