Control placement of a button within a text widget
- From: hgiese@xxxxxxxxxxxxx (Helmut Giese)
- Date: Tue, 29 Nov 2005 22:37:56 GMT
Hello out there,
I want to embed a button within a text widget - this is easy. However,
I also want it to be centered in the middle - this is hard (ok, hard
for me).
Here is what I have so far:
---
package require Tk
# just for re-sourcing this file
foreach w [pack slaves .] {destroy $w}
pack [text .t -width 12] -fill x
set s "This is line 1.
This is line 2.
This is line 3.
"
..t insert end $s
# this line helps a bit
#.t insert end " "
# now the button
..t window create end -align center -create \
[list button .t.btn -text Ok \
-command {puts "Click"}]
---
The button will appear flush left. I thought that '-align center'
would be the option I need, but this appears to not be the case.
If I uncomment the line marked by "# this line helps a bit" the button
will be pushed over to the right. I could experiment how many spaces
to fill in to have the button in the middle, but this is a kludge:
- If the text window is made wider, the button will stay at its place
and won't be centered any more.
- If the user changes the font, the button is likely to not be
centered any more.
Tcl (and Tk) being what it is, I am sure that there is a solution for
what I want. Any hints in this direction will be greatly appreciated.
Best regards
Helmut Giese
.
- Follow-Ups:
- Re: Control placement of a button within a text widget
- From: slebetman@xxxxxxxxx
- Re: Control placement of a button within a text widget
- Prev by Date: Re: Embedded TCL and Single File Executables
- Next by Date: Re: OT: using GPL'ed icons
- Previous by thread: Embedded TCL and Single File Executables
- Next by thread: Re: Control placement of a button within a text widget
- Index(es):