wxpython and zoom/pan image

R

rzzzwilson

Hi,

I've googled for this, but can only find things like openlayers that
is a web-based javascript solution.

I need to display an image at various zoom levels and want to allow
the user to pan around in the Google maps style, that is, left-click
hold and drag. The code should also action double-clicks on the image
(but that's easy).

There are no 'standard' wxpython widgets that allow this. Can anyone
point me to information on how to implement such a thing, or maybe
some working code?

Thanks,
Ross
 
D

Dave Angel

Hi,

I've googled for this, but can only find things like openlayers that
is a web-based javascript solution.

I need to display an image at various zoom levels and want to allow
the user to pan around in the Google maps style, that is, left-click
hold and drag. The code should also action double-clicks on the image
(but that's easy).

There are no 'standard' wxpython widgets that allow this. Can anyone
point me to information on how to implement such a thing, or maybe
some working code?

Thanks,
Ross
These are all (?) of the pieces in my working image display program. It
rotates and scales. It's an exercise to the reader to divide it up.
For example, you don't want to rerun all of this every time the mouse
drags a little. So these are in two different places, where the first
group only happens when you change the image file, or rotate by an angle
other than 90 degrees
self._img = wx.Image(self.fname, wx.BITMAP_TYPE_ANY)
self._img = wx.EmptyImage(42, 42, True) #create a plain
black image, 42 x 42 pixels
self._img = self._img.Rotate90()
self._img = self._img.Rotate(-radians, center)

img2 = img1.Scale(self.imageW()*scale/1000,
self.imageH()*scale/1000) #this is where image is scaled to final bit
dimensions. It's clipped during drawBitmap()
tracer("drawStuff Scale", "draw")
bmp = wx.BitmapFromImage(img2)

w, h = self.GetClientSize() #self is a
subclass of Panel
self.buffer = wx.EmptyBitmap(w, h)
dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
dc.DrawBitmap(bmp, cornerX, cornerY, False)

Hope this helps. I tied the scaling to the mousewheel, and used drag to
move the cornerX and cornerY. Notice they can go negative, as well as
positive.
 
B

Barak, Ron

Hi Ross,
You probably would get more focused answers if you addressed the question to the wxPython list at (e-mail address removed)
As for your question, seeing your (simplified) code might help: out of hand, what you want to do is catch the events you're interested in (e.g., double-left-click) and create functions/class-instances that would perform the needed actions.
I'd suggest reading "wxPython in Action" (ISBN 1-932394-62-1) as it would give you most of the answers you seek.
Bye,
Ron.
 
E

edexter

 Hi Ross,
You probably would get more focused answers if you addressed the question to the wxPython list at (e-mail address removed)
As for your question, seeing your (simplified) code might help: out of hand, what you want to do is catch the events you're interested in (e.g., double-left-click) and create functions/class-instances that would perform the needed actions.
I'd suggest reading "wxPython in Action" (ISBN 1-932394-62-1) as it would give you most of the answers you seek.
Bye,
Ron.


-----Original Message-----
From: (e-mail address removed) [mailto:[email protected]]
Sent: Sunday, May 24, 2009 03:28
To: (e-mail address removed)
Subject: wxpython and zoom/pan image

I've googled for this, but can only find things like
openlayers that is a web-based javascript solution.
I need to display an image at various zoom levels and want to
allow the user to pan around in the Google maps style, that
is, left-click hold and drag.  The code should also action
double-clicks on the image (but that's easy).
There are no 'standard' wxpython widgets that allow this.  
Can anyone point me to information on how to implement such a
thing, or maybe some working code?
Thanks,
Ross- Hide quoted text -

- Show quoted text -


I think I remember seeing an example about zooming somewhere on the
wxpython list or wiki...
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top