Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

group box with title

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Can I do the group box like below in tk? I saw in a demo but do not understand how it was done. I don't think a frame can do that.

---- Group ------------
| |
| |
| |
| button button |
| |
| |
| |
| |
-----------------------
 
But frame can do!
Code:
  pack [frame .f -bg gold -width 100 -height 100]
  pack propagate .f 0
  pack [button .f.b1 -text 1] -side left
  pack [button .f.b2 -text 2] -side right
All subwidgets of the frame are displayed inside the frame.
To declare a widget a subwidget of an other widget, you make its path a subpath of the path of the parent.
Here the buttons are subwidgets of the frame becase their path .f.b1 or .f.b2 is a subpath of .f.

Normally the frame is sized to just contain its subwidgets.
So I added a [pack propagate .f 0] to avoid that and show a bigger frame. You can remove it to watch what appends.

Placing a subwidget inside its parent is a subtle task.

Good luck

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top