473,543 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tkinter canvas zooming (sortof)

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
May 26 '06 #1
1 4362
"Bob Greschke" <bo*@passcal.nm t.edu> wrote in message
news:Yv******** *************** *******@nmt.edu ...
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
May 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3994
by: mksql | last post by:
New to Tkinter. Initially, I had some code that was executing button commands at creation, rather than waiting for user action. Some research here gave me a solution, but I am not sure why the extra step is necessary. This causes the "graph" function to execute when the button is created: Button(root, text='OK', command=graph(canvas))) ...
1
10457
by: Elaine Jackson | last post by:
Newbie. Playing with the 'turtle' module and wondering if there's a way to save the graphics you make with it. The documentation itself has nothing to say about this, nor (as far as I can tell) does the FAQ list at python-dot-org. Any pointers would be very much appreciated. (In related news, I would also like to find out what's going on...
1
2955
by: syed_saqib_ali | last post by:
Please take a look at and run the code snippet shown below. It creates a canvas with vertical & Horizontal scroll-bars. If you shrink the window to smaller than the area of the canvas, the scroll-bars work as advertised. That's great. However, if you click the Left Mouse button, it calls code which expands the width of the canvas by 100...
0
3568
by: syed_saqib_ali | last post by:
Below is a simple code snippet showing a Tkinter Window bearing a canvas and 2 connected scrollbars (Vertical & Horizontal). Works fine. When you shrink/resize the window the scrollbars adjust accordingly. However, what I really want to happen is that the area of the canvas that the scrollbars show (the Scrollregion) should expand as the...
3
4473
by: Tuvas | last post by:
I'm trying to display a picture on a Tkinter Canvas. It seems to work fine the first time that it is displayed. However, subsequent times running shows an error like this: TCLerror: Wrong # args: should be ".-1211472948 .-1211470996 addtag tag searchCommand ?arg arg ...? My code works like this: if (pic):
5
14922
by: Dean Allen Provins | last post by:
I need to determine the size of a canvas while the process is running. Does anyone know of a technique that will let me do that? Thanks, Dean
1
6084
by: 3056kgw | last post by:
I'm fairly new to programming GUI's and I'm trying to control the zoom of a figure from matplotlib using a scrollbar. I can create the canvas for the figure with... import matplotlib import Tkinter as Tk from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg ... root = Tk.Tk() ... canvas = FigureCanvasTkAgg(f, master=root)
4
2863
by: Davy | last post by:
Hi all, I have written a simple Tkinter program, that is draw a rectangle in a canvas, when I press Up key, the rectangle move up. But the program seems work not properly? My environment is Python2.5+PythonWin. ##---------------------- from Tkinter import * class MyApp:
3
2963
by: joshdw4 | last post by:
I hate to do this, but I've thoroughly exhausted google search. Yes, it's that pesky root window and I have tried withdraw to no avail. I'm assuming this is because of the methods I'm using. I guess my question is two-fold. 1) How do I get rid of that window? 2) Any comments in general? I am just learning python (and coding with classes), so...
0
7411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7354
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5888
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4898
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1824
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
643
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.