[ltk-user] Grid question

Bill Ramsay ramsayw1 at verizon.net
Tue Aug 15 13:09:50 UTC 2006


Peter Herth wrote:
> Hi Bill,
>
> sorry for a late (and a bit short) answer, but your mail caught me
> during travel, but I will try what is possible in a short.
>
>> I'm new to Ltk.   I seem to get it to work fine and have seen enough to
>> want to really get familiar with it.  However, I have a few questions
>> about the layout managers.   Basically, I want to be able to place
>> things anywhere on the screen and have them stay relative to one another
>> when the screen  is resized.
>>
>> When creating a grid, who owns it?    If I want a frame to be a grid of
>> four by four and to place buttons at 1,0  and 2,3, how is that done?
>> It seems that when I try this the first button goes to 0,0 and the
>> second button to 1,1.
>>
>> Also, how do you create an empty frame of a specific size?    Or a nil
>> (*tk*) window of a specific size?
>>
>
> In general, try to avoid grid rows/columns which are completely empty,
> as they get shrunken to zero size. The grid layout is owned by the
> container which owns it, that is either the toplevel window or the
> frame whichin the grid is. (the master of the widgets you grid). The
> sizing of the grid rows/columns is determined by the minimum size of
> the widgets contained in the cells and by the weight  of the
> row/column. You can adjust the weight by using grid-rowconfigure (or
> grid-columnconfigure respectively) with the keyword :weight and a
> parameter between 0 and 1, the heigher ones take more space when
> resizing than the smaller ones.
> But I personally use grid only when I really have to put things into a
> grid, for most layouts I prefer the pack manager. The pack seems to be
> quite restricted, you can only pack horizontally via :side :left (or
> :right) or verticaly with :side :top (or :bottom). The magic trick is
> to use frames to create containers for widgets packed in the other
> direction. So in many applications I write, the top level pack goes
> from the top to the bottom of the window, and whithin that I have
> subframes which pack their contained widgets in a horizontal matter.
> You can see an example for it in the ltktest program, which packs a
> canvas on the top of the window and a frame at the bottom, which
> contains a horizontal row of widgets. With pack you have to use the
> :expand and :fill arguments to specify the resizing behaviour.
> I hope this helps, don't heasitate to ask more :)
>
> Peter
> _______________________________________________
> ltk-user site list
> ltk-user at common-lisp.net
> http://common-lisp.net/mailman/listinfo/ltk-user
>
Thanks for getting back to me.   Actually, I'm much father along with 
Ltk now and like it a lot.
Pack does the job fine.

Two quick comments.    You should really mention on your web site that 
ltktest is INSIDE
the ltk.lisp code.    It took me forever to figure out why I couldn't 
find the program anywhere.
The other comment is that it's not quite true that you don't need to 
know TK.    I dug out my old
Perl/Tk book and it made understanding some of the formats a lot easier.

The library works great, however, and I see no reason why it can't be my 
GUI of choice for Lisp.   

Bill



More information about the ltk-user mailing list