Implementing zoom and pan on pygtk
- From: Billy Okal <b okal jacobs-university de>
- To: gtk-list gnome org
- Subject: Implementing zoom and pan on pygtk
- Date: Mon, 22 Jun 2009 20:13:26 +0200
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
so far I have this
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]