[wxPython-users] Scrollbars around the image when button is pressed....

Robin Dunn robin at alldunn.com
Mon Feb 4 10:46:17 PST 2008


Varsha Purohit wrote:
> Hi All,
>     I have made a simple panel in wxpython where i am loading an image 
> from the folder. I have a button named zoomin. When i press this button 
> a pair of horizontal and vertical scrollbars should appear on the image 
> panel nearby image. so that we can see the zoomed image properly. I am 
> trying to use wx.Scrollbar but i am not able to fix the scrollbars 
> properly around the image. 


Use a wx.ScrolledWindow instead of a wx.Panel, and then set the virtual 
size of the wx.ScrolledWindow to the size of the image you want to 
display, and reset the virtual size when you want to zoom/unzoom.  If 
the virtual size is larger than the physical size then the scrollbars 
will automatically appear and allow the user to scroll.  You can use a 
wx.StaticBitmap to display the image, but in this case you'll probably 
be better off just drawing it yourself in a EVT_PAINT handler for the 
scrolled window.


-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list