Re: Tk Packer Advice Needed

From: Erick Gallesio <>
Date: Thu, 27 May 1999 10:49:51 +0200 (CEST)

Michael Wahrman writes:
> Dear Fellow Tk Users
> Although I have tried nearly every combination of the options that the
> Ousterhout book suggests, I can not figure out how to make the packer go to a
> new line. I.e. I have (say) 20 parameters: say I want 4 per line and 5 lines in
> a window. How in the world do I do that.

You should use the "grid" geometry manager instead of "pack". It is
exactly done for such tasks.
Hereafter is a piece of code which illustrate this

    (require "Tk-classes")

    ;;The following deiconify will not be necessary for 4.0
    (wm 'deiconify *root*)

    (dotimes (i 20)
      (let ((but (make <Button> :text i)))
        (grid but :row (quotient i 4) :column (modulo i 4) :sticky "news")))

It does not mean that you can do that with pack but it will be more
complicate but you will need to embed your objects in frames that you
arrange horizontally, or vertically.

Hope it helps.

                -- Erick
Received on Thu May 27 1999 - 11:13:53 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST