Re: Control placement of a button within a text widget



Bryan Oakley wrote:
> slebetman@xxxxxxxxx wrote:
> > # Note how I surround the button with space bars to maintain
> > # correct center.
> >
>
> Why do you add spaces "to maintain the correct center"? You can just add
> the ctr tag to the created window after the fact with '.t tag add'.

Ah, didn't realise I could tag a window. I tried:

..t window create end ..... tag

and it didn't work. Then when I read (quickly scanned) the docs I
couln't find a way to tag a window. Thanks. Then the solution is
simply:

pack [text .t -width 12] -fill x
..t tag configure ctr -justify center
set s "This is line 1.
This is line 2.
This is line 3.
"
..t insert end $s
..t window create end -align center -create \
[list button .t.btn -text Ok \
-command {puts "Click"}]
..t tag add ctr {end - 1 lines} end

.


Quantcast