Two simple (I hope) QS about grid 
Author Message
 Two simple (I hope) QS about grid

Hello,

1. This small program (see below pls) works fine but,
if I use the mouse to resize the "master" window, the
base of the vertical scroll bar begins to disapear instead
of shrink to the appropriate size! Is there a way
to avoid this? (BTW, I'm testing on 8.1a2 windows95).

2. How are the - x and ^ used? I can't understand the
grid man page! A very small example would be a must.

TVMIA for any help

================================== The small program ...
set tw    .frame
set tlfr  ${tw}.
set fr    ${tlfr}fr
set lb1   ${fr}.lb1
set lb2   ${fr}.lb2
set vsb   ${fr}.vsb

proc FI {a} {
    puts $a

Quote:
}

proc vvv {args} {
    global lb1 lb2
    eval $lb1 yview $args
    eval $lb2 yview $args

Quote:
}

proc s12 {args} {
    global vsb lb1 lb2
    eval $vsb set $args
    eval $lb2 yview moveto [expr [lindex [$lb1 yview] 0]+0.]

Quote:
}

proc s21 {args} {
    global vsb lb1 lb2
    eval $vsb set $args
    eval $lb1 yview moveto [expr [lindex [$lb2 yview] 0]+0.]

Quote:
}

toplevel $tw
wm title $tw "C{*filter*}teste 2"
frame $fr
listbox $lb1 -height 15 -width 10 -yscrollcommand s12
listbox $lb2 -height 15 -width 50 -yscrollcommand s21
bind $lb1 <FocusIn> {FI 1}
bind $lb2 <FocusIn> {FI 2}
bind $lb1 <Button> "focus $lb1"
bind $lb2 <Button> "focus $lb2"
for {set i 1} {$i<100} {incr i} {
    $lb1 insert end "tttt$i"
    $lb2 insert end "xxxxxxxxxxxxxxx$i"
Quote:
}

scrollbar $vsb -command vvv -orient vertical

pack $fr
grid columnconfigure $fr 0 -weight 0
grid columnconfigure $fr 1 -weight 1
grid columnconfigure $fr 2 -weight 0
grid rowconfigure    $fr 0 -weight 0
grid $lb1 -row 0 -column 0
grid $lb2 -row 0 -column 1
grid $vsb -row 0 -column 2 -sticky ns
============================================================

--
Por favor retire os Xs do endereco de email.
Please remove the Xs from email address.



Tue, 27 Mar 2001 03:00:00 GMT  
 Two simple (I hope) QS about grid

Quote:

> Hello,

> 1. This small program (see below pls) works fine but,
> if I use the mouse to resize the "master" window, the
> base of the vertical scroll bar begins to disapear instead
> of shrink to the appropriate size! Is there a way
> to avoid this? (BTW, I'm testing on 8.1a2 windows95).

> 2. How are the - x and ^ used? I can't understand the
> grid man page! A very small example would be a must.

Sorry that I don't have time to dig into your example and give you
detailed feedback but I heartily recommend _Effective Tcl/Tk
Programming_
(http://cseng.aw.com/bookdetail.qry?ISBN=0-201-63474-0&ptype=0) which
has a very good section on geometry managers including grid.

                                          Chris
--
Rens-se-LEER is a county.  RENS-se-ler is a city.  R-P-I is a school!



Fri, 30 Mar 2001 03:00:00 GMT  
 Two simple (I hope) QS about grid

Quote:

> Hello,

> 1. This small program (see below pls) works fine but,
> if I use the mouse to resize the "master" window, the
> base of the vertical scroll bar begins to disapear instead
> of shrink to the appropriate size! Is there a way
> to avoid this? (BTW, I'm testing on 8.1a2 windows95).

> 2. How are the - x and ^ used? I can't understand the
> grid man page! A very small example would be a must.

> TVMIA for any help

> ================================== The small program ...
> set tw    .frame
> set tlfr  ${tw}.
> set fr    ${tlfr}fr
> set lb1   ${fr}.lb1
> set lb2   ${fr}.lb2
> set vsb   ${fr}.vsb

> proc FI {a} {
>     puts $a
> }

> proc vvv {args} {
>     global lb1 lb2
>     eval $lb1 yview $args
>     eval $lb2 yview $args
> }

> proc s12 {args} {
>     global vsb lb1 lb2
>     eval $vsb set $args
>     eval $lb2 yview moveto [expr [lindex [$lb1 yview] 0]+0.]
> }

> proc s21 {args} {
>     global vsb lb1 lb2
>     eval $vsb set $args
>     eval $lb1 yview moveto [expr [lindex [$lb2 yview] 0]+0.]
> }

> toplevel $tw
> wm title $tw "C{*filter*}teste 2"
> frame $fr
> listbox $lb1 -height 15 -width 10 -yscrollcommand s12
> listbox $lb2 -height 15 -width 50 -yscrollcommand s21
> bind $lb1 <FocusIn> {FI 1}
> bind $lb2 <FocusIn> {FI 2}
> bind $lb1 <Button> "focus $lb1"
> bind $lb2 <Button> "focus $lb2"
> for {set i 1} {$i<100} {incr i} {
>     $lb1 insert end "tttt$i"
>     $lb2 insert end "xxxxxxxxxxxxxxx$i"
> }
> scrollbar $vsb -command vvv -orient vertical

> pack $fr
> grid columnconfigure $fr 0 -weight 0
> grid columnconfigure $fr 1 -weight 1
> grid columnconfigure $fr 2 -weight 0
> grid rowconfigure    $fr 0 -weight 0
> grid $lb1 -row 0 -column 0
> grid $lb2 -row 0 -column 1
> grid $vsb -row 0 -column 2 -sticky ns
> ============================================================

> --
> Por favor retire os Xs do endereco de email.
> Please remove the Xs from email address.

Merge the following lines into above script and it should work.

        pack $fr -expand 1 -fill both
        grid rowconfigure    $fr 0 -weight 0

--
Paul Duffin

IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880      International: +44 1962-816880



Fri, 30 Mar 2001 03:00:00 GMT  
 Two simple (I hope) QS about grid
Quote:

> Hello,

> 1. This small program (see below pls) works fine but,

OK. I already know how to do it! I misunderstood the meaning
of the "weight" parameter. The only row MUST be configured to
have a weight of 1 instead of 0.
I still don't understand how to use the ^, x and - referred
on the grid man pages. Any references to any docs are welcome.
Thanks
Paulo
--
Por favor retire os Xs do endereco de email.
Please remove the Xs from email address.


Sat, 31 Mar 2001 03:00:00 GMT  
 Two simple (I hope) QS about grid

Quote:


> > Hello,

BTW, is there any way to make a grided listbox get smaller or shorter
depending on the resize of the frame window it is in?
In fact, if I tell the listbox the number of lines, it limits the
size of the LB to that number of lines, even if if I resize the window
to a greater y value (using the mouse for ex.). If I don't specify the
number
of lines or set it to zero, the initial window may me too large
depending
on the number of elements I put into the list!

The only way I found to work was limiting the size of the top window
using the wm command and then set the number of lines of the LB to zero,
but I think there will be a better way.

Regards
Paulo

--
Por favor retire os Xs do endereco de email.
Please remove the Xs from email address.



Sun, 01 Apr 2001 03:00:00 GMT  
 Two simple (I hope) QS about grid

Quote:



> > > Hello,

> BTW, is there any way to make a grided listbox get smaller or shorter
> depending on the resize of the frame window it is in?
> In fact, if I tell the listbox the number of lines, it limits the
> size of the LB to that number of lines, even if if I resize the window
> to a greater y value (using the mouse for ex.). If I don't specify the
> number
> of lines or set it to zero, the initial window may me too large
> depending
> on the number of elements I put into the list!

If you are using the grid geometry manager, pay close attention to the
-weight option in rowconfigure and columnconfigure. For pack, make use
of -fill and -expand. It's fairly simple.

Quote:

> The only way I found to work was limiting the size of the top window
> using the wm command and then set the number of lines of the LB to zero,
> but I think there will be a better way.

This will guarantee it will shrink as small as possible, and is a
perfectly usable solution. For simple cases you can set the listbox to
the size you want, do an update idletasks, grab the window geometry,
reset the number of lines to zero, then reset the geometry of the window
to what you have saved from the previous step.

I posted an example of this with the text widget earlier in the week,
though I don't remember the subject line.

--
Bryan Oakley
ChannelPoint, Inc.



Mon, 02 Apr 2001 03:00:00 GMT  
 Two simple (I hope) QS about grid

Quote:



> > > Hello,

> BTW, is there any way to make a grided listbox get smaller or shorter
> depending on the resize of the frame window it is in?
> In fact, if I tell the listbox the number of lines, it limits the
> size of the LB to that number of lines, even if if I resize the window
> to a greater y value (using the mouse for ex.). If I don't specify the
> number
> of lines or set it to zero, the initial window may me too large
> depending
> on the number of elements I put into the list!

> The only way I found to work was limiting the size of the top window
> using the wm command and then set the number of lines of the LB to zero,
> but I think there will be a better way.

> Regards
> Paulo

> --
> Por favor retire os Xs do endereco de email.
> Please remove the Xs from email address.

Look at -sticky option on grid configure and -weight option on
grid row/columnconfigure.

--
Paul Duffin

IBM UK Laboratories Ltd., Hursley Park nr. Winchester
Internal: 7-246880      International: +44 1962-816880



Fri, 06 Apr 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Two Simple Qs:

2. two Qs from a nubie

3. Few simple qs

4. Simple Qs: Do I need to uninstall before install

5. !A simple question (I hope)...

6. A simple (I hope) Scheme question

7. Simple question- I hope

8. Simple algorithmic question I hope :-)

9. Simple question (I hope)

10. simple (I hope) asm problem

11. a simple ( i hope ) prolog problem

12. Simple Question (I hope)

 

 
Powered by phpBB® Forum Software