Pan/Zoom Image class?

K

Kurt

Hi All,

I'm just getting started rewriting a small CAD/GIS like application
for designating outlines of objects in photographs/images in Python.
Is there a class out there that already handles panning and zooming
along with lines that have been drawn on top of the object? If got a
simple scrolling canvas working and user designation of objects with
the mouse. But I'm wondering if there is an elegant solution that
handles zooming too. I'm using Tkinter with a canvas, but at this
point I could switch to any GUI package. Any recommendations?

Thanks!
-kurt

e.g. here is what i'm currently doing in a stripped down test program:

#!/usr/bin/env python
from Tkinter import *

class ScrolledCanvas(Frame):
def __init__(self, parent=None, color='white'):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.photo=PhotoImage (file="01pc.gif")

canv=Canvas(self, bg=color, relief=SUNKEN)
canv.config(width=250, height=500)
canv.config(scrollregion=(0,0, 300, 1000))
canv.create_image(10,10, image=self.photo, anchor=NW)

sbarY=Scrollbar(self)
sbarY.config(command=canv.yview)
canv.config(yscrollcommand=sbarY.set)
sbarY.pack(side=RIGHT, fill=Y)

sbarX=Scrollbar(self,orient='horizontal')
sbarX.config(command=canv.xview)
canv.config(xscrollcommand=sbarX.set)
sbarX.pack(side=BOTTOM, fill=X)

canv.pack(side=LEFT, expand=YES, fill=BOTH)
Button(text="quit", command=self.quit).pack(fill=X)
if __name__ == '__main__':
ScrolledCanvas().mainloop()
 
D

Diez B. Roggisch

Hi,
I'm just getting started rewriting a small CAD/GIS like application
for designating outlines of objects in photographs/images in Python.
Is there a class out there that already handles panning and zooming
along with lines that have been drawn on top of the object?  If got a
simple scrolling canvas working and user designation of objects with
the mouse.  But I'm wondering if there is an elegant solution that
handles zooming too.  I'm using Tkinter with a canvas, but at this
point I could switch to any GUI package.  Any recommendations?

You could go for pygame and/or pyopengl. I'm not sure if there is a way to
embed a pygame-window or opengl window into a canvas, but maybe you can
roll out your own toolkit-implementation on top of pygame. (There is even
one, based on pygame and opengl, but it seems to work only under windows,
which I don't have)

Diez
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top