You'll probably want to do the reconfiguration each time that the user
resizes the window. You can do this by creating a binding to the
<Configure> event for the canvas:
bind $sc.fr2.c <Configure> {
$sc.fr2.c configure -scrollregion [$sc.fr2.c bbox all]
}
The book Effective Tcl/Tk Programming (McLennan, Harrison) has a nice
section about creating resizeable canvases:
http://www.scriptics.com/resource/doc/books
We use that section in our Effective Tcl/Tk Programming course at
Scriptics.
Hope this helps,
Lee
______________________________________________________
Lee F. Bernhard lee.be...@scriptics.com
phone: (650) 843-6914 fax: (650) 843-6909
Scriptics Corporation http://www.scriptics.com
The Tcl Platform Company
canvas $sc.fr2.c -relief sunken -width 500 -height 300 -bd 2 \
-yscrollcommand "$sc.fr2.scroll set" -scrollregion {0 0 0 $rows} \
-confine true -yscrollincrement 25 -bg white
This has a problem with the variable $rows. Is it possible to do something
like this, maybe utilising "eval"? I need to keep it dynamic, as I don't
know how much data I will be trying to display.
Thanks for any help,
James.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
Why don't you reconfigure the scrollregion of the canvas --
After adding data just give
$sc.fr2.c configure -scrollregion [$sc.fr2.c bbox all]
This should work. I am also using the same technique in one of my apps.
Moinak.
> I am trying to set a dynamic size canvas, but I can't seem to do it.
> I have tried the following:
>
> canvas $sc.fr2.c -relief sunken -width 500 -height 300 -bd 2 \
> -yscrollcommand "$sc.fr2.scroll set" -scrollregion {0 0 0 $rows} \
> -confine true -yscrollincrement 25 -bg white
>
> This has a problem with the variable $rows. [snip]
Presumably Tcl is giving you an error, something like "expected an integer but
got '$rows'". What you want is -scrollregion [list 0 0 0 $rows] instead of
-scrollregion {0 0 0 $rows}. This is because braces ({}) in Tcl always treat
their contents literally, so one of the coordinates in your scroll region is
the literal string "$rows".
- Eric
--
----=--=-=-==-===-=====//=====\\=====-===-==-=-=--=----------------- <>< -
"God is real, unless // Name: \\ Eric Galluzzo | Software Engineer | SDRC
declared integer." // E-mail: \\ Eric.G...@sdrc.com
// SDRC WWW: \\ http://www.sdrc.com/
-- Unknown // http://www.geocities.com/SiliconValley/Vista/5567/
--=-=-==-===-=====//===============\\=====-===-==-=-=--=------------ <>< -
: canvas $sc.fr2.c -relief sunken -width 500 -height 300 -bd 2 \
: -yscrollcommand "$sc.fr2.scroll set" -scrollregion {0 0 0 $rows} \
: -confine true -yscrollincrement 25 -bg white
: This has a problem with the variable $rows. Is it possible to do something
: like this, maybe utilising "eval"? I need to keep it dynamic, as I don't
: know how much data I will be trying to display.
You need to say
[list 0 0 $cols $rows]
I'm afrayd that saying scrollwidth to 0 is not a good idea. I've
experienced very interesting behavoir of canvas if it got
one-point long line or something simular. May be just setting
scrollwidth to window width
[list 0 0 500 $rows]
BTW name rows suggests that its value isn't expressed in pixels. May be
you have mean
[list 0 0 500 [expr $rows*$rowheight]]
?
: Thanks for any help,
: James.
: -----== Posted via Deja News, The Leader in Internet Discussion ==-----
: http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
--
--------------------------------------------------------
I have tin news and pine mail...
Victor Wagner @ home = vitus @ orc . ru