I've been trying to do something extremely simple in tcl, and have
been running into roadblocks..
Namely, I've been trying to create an application with three panes,
using 'pack' to pack the first two panes into the top window, and then
using 'grid' to subdivide the lower pane. I want something like this:
----------------------------
| |
----------------------------
|TEXT |TEXT2 |
----------------------------
where TEXT is left justified to one grid panel, and TEXT2 is LEFT
justified to the other grid panel in the second pane.
In any case, no matter what I do, I can't get the text to left
justify. It sits in the center of the pane. I'm wondering, is this an
inherent way that grid works? And is there a way to see exactly which
screen real estate is controlled by which grid? Is there a 'pack/grid'
tutorial?
Thanks much,
Ed
(
pps - fyi, here is the code I'm using, where 'banner_image.gif' is any
long, thin gif..
wm title . {mydisplay}
image create photo banner_image.gif -file banner_image.gif
winfo children .
label .l -borderwidth 1 -image banner_image.gif -relief solid -text a
pack .l -side top
winfo children .
frame .f -bd 2 -borderwidth 2 -width 50
grid columnconfigure .f 1 -minsize 50 -pad 0
grid columnconfigure .f 2 -minsize 50 -pad 0
pack .f -side top
winfo children .f
label .f.l -text AHA -anchor w -justify left
grid .f.l -in .f -column 1 -row 1 -columnspan 1 -rowspan 1 -sticky
news
winfo children .f
label .f.l2 -text AHA2 -anchor w -justify left
grid .f.l2 -in .f -column 2 -row 1 -columnspan 1 -rowspan 1 -sticky
news
)
man pages, examples on the wiki. one trick I used early on (and occasionally
still do for complicated layouts that just aren't doing what I want)
if to color the main window, every frame, and every widget bright and
different colors - this allows you to see what is happening.
as to you immediate problem, you use -justify left on you label widgets
but this doesn't do what you think. looking at the man pages you will see
<http://www.tcl.tk/man/tcl8.4/TkCmd/options.htm#M-justify>
which tells you this applies to multiple lines of text and how they line up
with each other, not how the block of text (or the image) lines up within
the widget itself. For that you want to use -anchor. another option is
to not use -sticky news in your grid command, but just -sticky w. This
will prevent the widget from growing, so it will be the size of the text only,
and stuck to the side of the grid "cell".
Bruce
Hi Ed,
#1) The problem is with the pack .f command, not the grid. You need
the -expand and -fill options.
#2) You need to add weights to the columns as well.
-Brian