Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie - Scrollable canvas not working 1

Status
Not open for further replies.

godatguitar

Programmer
May 8, 2003
33
0
0
GB
Hi

I am very new to tcl, so sorry if this is a stupid question...
I have a canvas that I have attached the vertical scrollbar to, and i have set the scrollregion to 0 0 0 800.
When running the program, the scrollbar moves correctly, but the canvas does not move at all, and it seems that the scrollbar is not attached to the canvas.
I am using Visual tcl to write this code as I am very new to tcl.
I belive the problem lies with either the yscrollcommand with the canvas, or the command yview with the scrollbar.
Any help would be great!
Thanks in advance

:)
 
canvas <canvas name> -yscrollcommand &quot;<scrollbar name> set&quot;
scrollbar <scrollbar name> -command &quot;<canvas name> yview&quot;

When you build the canvas, you tell it (-yscrollcommand) what widget (scrollbar) will control its scroll. Then, when you build the scrollbar, you tell it (with -command) what widget's &quot;yview&quot; it controls.


Bob Rashkin
rrashkin@csc.com
 
Hi
Thanks for the reply. I have the following:

Canvas name .can24
Scrollbar name .scr33

yscrollcommand .top23.can24.scr33 set
scrollbar command .top23.can24 yview

Should this not do the trick? It is, i think, what you said!
 
Almost. If I read you right, it should be:
-yscrollcommand .top23.scr33 set

The scroll bar is not an extension of the canvas; it's a separate widget.

Bob Rashkin
rrashkin@csc.com
 
Hi Again


This does not work as it comes up with the following error:

invalid command name &quot;.top23.scr33&quot;
 
If I resize the canvas, the scrollbar adjusts its size correctly, ie, the bar becomes smaller and i am able to move it up and down, it just doesnt scroll the canvas.
 
OK. You must have a syntax error. Is this what you have:

canvas .top23.can24 -yscrollcommand &quot;.top23.scr33 set&quot;
scrollbar .top23.scr33 -command &quot;.top23.can24 yview&quot;

exactly, or is it something else?

Bob Rashkin
rrashkin@csc.com
 
Here is what i think i have:

-yscrollcommand &quot;$base.can24.scr23 set&quot; -yscrollincrement 10

scrollbar $base.can24.scr23 -command &quot;$base.can24 yview&quot;


And i think $base is defined at .top23

The link should show you the total code.
Cheers
 
Assuming that &quot;-yscrollcommand ...&quot; comes inside the canvas definition or in a &quot;<canvas name> configure&quot; statement, I still think you don't want to define the scrollbar widget under the canvas widget ($base.can24.scr33). It should be a separate widget ($base.scr33).

Bob Rashkin
rrashkin@csc.com
 
by the way, the link is broken.

Bob Rashkin
rrashkin@csc.com
 
Hi Again


I have sent an email to your address:
rrashkin@csc.com

With the code attached. The link should work, it works for me and a mate on a different computer.

 
I've seen the file and got the mistake.
It's a serious mistake.

You attached a srollbar to a canvas but your canvas contains nothing. To insert an item inside a canvas, you need a script similar to that:
Code:
  canvas .c
  .c create text ...
  .c create image ...

If you create a widget that is son of the canvas, this widget is not inside the canvas (maybe behind or below).
But destroying the canvas will destroy the children.
Such children are best for toplevels or frames that are containers and manage their children.
Canvases manage only their items (those created with .c create ...).

I don't know how to do the right job with VTcl.

HTH

ulis
 
Many thanks for the reply.

As you may see from the program, i want to build frames onto a canvas, each frame having a question in and several radiobuttons with answers to chose from.
I want to be able to scroll this whole page, so that i can fit many questions, ie frames, on the page.
Is this possible, and if so, HOW?
A sample of code would be great, if not how to modify my code to fix would be better!

Many thanks

 
All your widgets should be in a frame, and what you want is a scrolled frame.
Some packages exist that do that.

For a fruitful data mining:

Good luck

ulis
 
Many, many thanks for your help everyone.

I REALLY appreciate it!


:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top