Pan/Zoom Image class?

Kurt kurt at etool.com
Wed Oct 22 11:23:45 EDT 2003


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()




More information about the Python-list mailing list