labelframe

A labelframe is a widget that holds other widgets, putting a (usually) visible border around them and a label (usually textual) that gives a human-visible description of the group of widgets as a whole.

This is the Tk/Tile widget, the labelframe. See man pages here:

https://www.tcl-lang.org/man/tcl8.5/TkCmd/labelframe.htm

and here, for the Tile-based themed labelframe:

https://www.tcl-lang.org/man/tcl8.5/TkCmd/ttk_labelframe.htm .


  Simulating with old versions of Tk

KPV 2003-07-24 -- For those who don't have 8.4, here's a very basic way of creating one. It only handles a few of the available options--the text always goes in the top left--but it's a good place to start. Two oddities that you should be aware of. First, the label cannot be a child of the frame, otherwise the text gets clipped. Second, the label needs some spacing inside the frame to avoid overlap. Here I did it by gridding in an empty frame, but this means that this widget can only be gridded in. There are other, probably better, ways of making this space but this works.

 proc xlabelframe {w args} {
    set fargs {}                                ;# Options for the frame
    set largs {}                                ;# Options for the label
    foreach {opt val} $args {
        if {$opt == "-text" || $opt == "-font" } {
            lappend largs $opt $val
        } else {
            lappend fargs $opt $val
        }
    }
    set w2 "${w}_label"            ;# CAN'T BE CHILD OF $w!!!
    eval frame $w -bd 2 -relief groove $fargs
    eval label $w2 $largs
    place $w2 -in $w -rely 0 -relx .05 -anchor w
    frame $w._spacer -height 10
    grid $w._spacer -row 0        ;# To avoid title overlap
    return $w
 }