[wxpython-users] Image selection with mouse
Christopher Barker
Chris.Barker at noaa.gov
Tue May 6 13:04:08 PDT 2008
Arthur Valadares wrote:
> I have the following GUI I wish to make: The user opens a bitmap image
> and selects a region of that image by clicking and making a closed shape
> (such as a circle, square, but actually it could be any closed shape).
> Then I should get that region, convert it to data (in a RGB or XYZ
> matrix for example) where I will do a bunch of calculations on it. But
> the issue is how to make this "select region" tool.
google around for "rubber band box" -- you'll see some sample code.
You can do this with wx.lib.floatcanvas also. It may be overkill, but if
you want to be able to zoom in and out of the image and pan around it,
it may be useful (use a ScaledBitmap). Even if if isn't right for you,
you can get ideas from it.
Take a look at the various demos that are with the source to see how to
do this kind of thing:
http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/Demos/
And here is the Rubber Band box code:
http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/FloatCanvas/floatcanvas/Utilities/GUI.py?view=markup
you might be able to plug that into your code with a little editing.
Here is some more info about FloatCanvas:
http://morticia.cs.dal.ca/FloatCanvas/
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the wxpython-users
mailing list