[pygtk] Fwd: implementing zooma and pan in pygtk

Billy Okal b.okal at jacobs-university.de
Tue Jun 23 01:49:24 WST 2009


----------  Forwarded Message  ----------

Subject: implementing zooma and pan in pygtk
Date: Monday 22 June 2009
From: Billy Okal <b.okal at jacobs-university.de>
To: pygtk at daa.com.au

hello

I am new to pygtk but familiar with python. I am trying to build a 
simple gui that allows zooming and panning (using arrows in 4 
directions) of images(maps) in png and svg formats. However I 
can't get the zooming an panning to work. Could someone offer 
help on this. I really need it fast so that I can start so real work 
using images. I already tried to use scrolling to implement the 
panning but I couldn't make it.

I show the images like this
im = gtk.Image()
im.set_from_file("something.png")
.
.
win.show_all

Also I have this so far;
I have buttons eg for zoomout;
self.z_out = gtk.Button(stock=gtk.STOCK_ZOOM_OUT)
self.z_in.connect("clicked", self.zoomin, width, height)

then I have this function
def zoomout(self, widget, width, height):
        w, h = hzoomout(width, height)
        im = self.image
        pixbuf = gtk.gdk.pixbuf_new_from_file("bremen.png")
        scaled_buf = 
pixbuf.scale_simple(w,h,gtk.gdk.INTERP_BILINEAR)
        im.set_from_pixbuf(scaled_buf)
        im.show()

hzoomout is just a small function that computes the new height 
and width based on some scale



Thanks in advance

-- 
Bill






More information about the pygtk mailing list