packing problem

From: Torsten Mohr (tmohr_at_s.netic.de)
Date: 12/31/03


Date: Wed, 31 Dec 2003 08:52:53 +0100

Hi,

i have a problem with a script that i wrote.

There's a menu and two frames. The upper frame contains some
buttons and the lower one consists of a canvas and two scrollbars.
The canvas should expand and fill the screen, so it is best
viewable.

The upper frame is managed with "pack", the lower frame also,
but its contents are managed by "grid".

If i expand the window, the canvas keeps its old size and the
frame that contains the canvas can be seen, which should not
happen.

If i shrink the window, the scrollbars can't be seen any more,
this should also never happen.

I tried "pack propagate" on ".cc" and on ".", but it did not
help.

Can anybody tell me what's wrong?

Thanks for hints,
Torsten.

Here's the script for reference:
#! /usr/bin/wish

menu .menu -tearoff 0

menu .menu.file -tearoff 0
menu .menu.edit -tearoff 0

.menu add cascade -label "File" -menu .menu.file -underline 0
.menu.file add cascade -label "Save" -command "save file"

.menu add cascade -label "Edit" -menu .menu.edit -underline 0

. configure -menu .menu

frame .f -relief sunken -padx 2 -pady 2 -bg red
button .f.quit -text "quit" -command "exit"
button .f.move -text "move" -command "newcmd move"
button .f.add -text "add" -command "newcmd add"
button .f.delete -text "delete" -command "newcmd delete"

pack .f.quit -side left
pack .f.move -side left
pack .f.add -side left
pack .f.delete -side left

pack .f -side top -fill x -expand 0

frame .cc -bg green
canvas .cc.c -width 320 -height 240 -xscrollcommand ".cc.v set"
-yscrollcommand ".cc.h set"
scrollbar .cc.v -command ".cc.c yview" -orient vertical
scrollbar .cc.h -command ".cc.c xview" -orient horizontal
#.cc.c configure -xscrollcommand ".cc.v set"
#.cc.c configure -yscrollcommand ".cc.h set"

grid .cc.c -row 0 -column 0 -sticky news
grid .cc.v -row 0 -column 1 -sticky ns
grid .cc.h -row 1 -column 0 -sticky ew

grid rowconfig .cc.c 0 -weight 10
grid columnconfig .cc.c 0 -weight 10

pack .cc -side top -fill both -expand yes

pack propagate . 1

set oldc "move"
#set c "move"
#.f.move configure -relief sunken

proc newcmd c {
        global oldc
        .f.$oldc configure -relief raised
        .f.$c configure -relief sunken
        set oldc $c
}

newcmd move

proc save name {
}


Quantcast