Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is there a simple way to create a "labelled line"?

1 view
Skip to first unread message

Adrian Davis

unread,
Oct 22, 2002, 9:06:48 AM10/22/02
to
Is there a simple way to create a "labelled line"? Something like a
labelframe but with a horizontal line only.

For example...

==Label Text=================================

...where the "=" form a "groove" relief line.

Many Thanks,
=Adrian=

coyotes rand mair fheal

unread,
Oct 22, 2002, 12:00:12 PM10/22/02
to
In article <c1459734.02102...@posting.google.com>,
adrian...@lewisham.gov.uk (Adrian Davis) wrote:

frame .linedLabel -background purple
frame .linedLabel.line -background grey -relief sunken -bd 2
label .linedLabel.label -background grey -text "EAT ME DRINK ME"
place .linedLabel.line -x 0 -relwidth 1 -y -3 -rely .5 -height 6
place .linedLabel.label -x 30 -width 150 -y -7 -rely .5 -height 14

backgrounbd colors are to distinguish widgets
.linedLabel can be packed instead

.linedLabel configure -background purple
. configure -background orange
place .linedLabel -x 0 -rely .5 -relwidth 1 -height 20

ulis

unread,
Oct 22, 2002, 5:27:18 PM10/22/02
to
> ==Label Text=================================
>
> ...where the "=" form a "groove" relief line.

Here is a proc:

proc labelledline {w width height dx text {anchor w}} \
{
canvas $w -width $width -height $height \
-highlightthickness 0 -selectborderwidth 0
set y [expr {$height / 2}]
incr y -2
$w create line 0 $y $width $y \
-fill SystemHighlightText
incr y
$w create line 0 $y $width $y \
-fill System3dDarkShadow
incr y 2
$w create line 0 $y $width $y \
-fill SystemHighlightText
incr y
$w create line 0 $y $width $y \
-fill System3dDarkShadow
incr y -2
$w create text $dx $y -anchor $anchor \
-text $text -tags text
$w create rectangle [$w bbox text] \
-fill SystemButtonFace -outline ""
$w raise text
}

And a test:
labelledline .ll 200 24 10 "a label"
pack .ll

HTH

ulis

William J Giddings

unread,
Oct 23, 2002, 4:37:18 AM10/23/02
to
This bit of code should see you us and running. This should provide you with
a megawidget that you can explcitly address. The you can modify the range of
definable parameters as you see fit.

Regards:

Will


# linedLabel.tcl

proc {linedLabel} {path args} {

set base $path

foreach {op val } $args {
switch -exact -- $op {
-text { set text $val}
-width { set width $val}
-configure { # your stuff goes here...}
} ;# end switch
} ;# end foreach

frame $base \
-borderwidth 0 -height 30 -width $width
frame $base.fra \
-borderwidth 2 -relief groove -height 5 -width [expr $width + 10]
label $base.lab1 \
-text $text
place $base.fra \
-x -5 -y 0 -rely 0.5 -anchor nw -bordermode ignore
place $base.lab1 \
-x 15 -y -8 -rely 0.5 -anchor nw -bordermode ignore

return $base
} ;# end proceedure

#test the megawidget

toplevel .a

set w [linedLabel .a.llab1 -text "Test 1" -width 100]
place $w -x 10 -y 10


# alternatively
place [linedLabel .a.llab2 -text "Test 2" -width 100] -x 10 -y 40

#end file

"Adrian Davis" <adrian...@lewisham.gov.uk> wrote in message
news:c1459734.02102...@posting.google.com...

0 new messages