Re: Proposed: new support for vertical anchor value of 'baseline in addition to n,s,c
- From: "Aric Bills" <aric.bills@xxxxxxxxx>
- Date: 30 Mar 2006 21:34:39 -0800
It's not a dumb idea, it just needs a TIP and some accompanying source
code.
In the meantime, you can accomplish your objective in one of two ways,
exemplified by procs alignAnchorN (for text items anchored n) and
alignAnchorS (for text items anchored s):
proc alignAnchorN {font baselineY} {
return [expr {$baselineY - [font metrics $font -ascent]}]
}
proc alignAnchorS {font baselineY} {
return [expr {$baselineY + [font metrics $font -descent]}]
}
# test code
font create font1 -family {Times New Roman} -size 24
font create font2 -family {Times New Roman} -size 18
set text1 "Text 1"
set text2 "Text 2"
toplevel .test
set c [canvas .test.c]
grid $c -sticky nsew
set baseline 100
$c create line 0 $baseline [winfo reqwidth $c] $baseline
$c create text 0 [alignAnchorN font1 $baseline] \
-anchor nw -font font1 -text $text1
$c create text [font measure font1 $text1] [alignAnchorS font2
$baseline] \
-anchor sw -font font2 -text $text2
.
- Follow-Ups:
- References:
- Prev by Date: Re: XmlRPC
- Next by Date: newbe q.: How to read windows path names from a file ?
- Previous by thread: Proposed: new support for vertical anchor value of 'baseline in addition to n,s,c
- Next by thread: Re: Proposed: new support for vertical anchor value of 'baseline in addition to n,s,c
- Index(es):