Tkinter canvas zooming (sortof)

B

Bob Greschke

I have a program that sucks in a list of equipment positions (Lats/Longs),
opens a Toplevel frame with a canvas set to, for example, 700x480 pixels,
and then does all of the calculations and plots the objects with 10-pixel
wide ovals and rectangles. Now I want to zoom in (or out), but I don't want
the ovals and rectangles to change size. I just want them to spread out or
get closer together. So scale() doesn't seem to be the way to go. What I
want to do is just make the "logical" canvas bigger and replot everything,
but when I reconfigure the canvas size to make it bigger the Toplevel frame
itself gets bigger. I want the frame to stay the same size, but still be
resizable. I have scrollbars, and they seem to work ok, and scrollregion
seems to do what it should, but I can't figure out how to get them to all
work together to do what I want. Help?

Thanks!

Bob
 
B

Bob Greschke

Bob Greschke said:
I have a program that sucks in a list of equipment positions (Lats/Longs),
opens a Toplevel frame with a canvas set to, for example, 700x480 pixels,
and then does all of the calculations and plots the objects with 10-pixel
wide ovals and rectangles. Now I want to zoom in (or out), but I don't
want the ovals and rectangles to change size. I just want them to spread
out or get closer together. So scale() doesn't seem to be the way to go.
What I want to do is just make the "logical" canvas bigger and replot
everything, but when I reconfigure the canvas size to make it bigger the
Toplevel frame itself gets bigger. I want the frame to stay the same size,
but still be resizable. I have scrollbars, and they seem to work ok, and
scrollregion seems to do what it should, but I can't figure out how to get
them to all work together to do what I want. Help?

Thanks!

Bob

After further fiddling...

I think I kind of figured this out. I could tell my plotting routine that
the canvas was twice as large as I originally made it, and it would draw
everything (i.e. if I drug the frame larger I could see more stuff off the
edge of the canvas), but the scrollbars would not "activate" so I could
scroll over to stuff off the edge of the canvas. What I was doing wrong was
not setting the scrollregion to the whole new canvas size that I used for
plotting. I kept setting it to the size of the visible canvas in the frame
or not setting it at all. I almost understand. :) Now all I have to do is
be able to grab the canvas and drag it around with the mouse and click on a
spot and have it center that spot and zoom in there.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top