[matplotlib-devel] patch submission - rectangle selector button select
Here is a patch for a new feature for the rectangle selector. it allows the user to specify which mouse button or buttons to use for the rectangle selection. Also included in the diff is a one line change to the rectangle_selector example code to demonstrate the use of the feature. Thanks, -BenIndex: lib/matplotlib/widgets.py === --- lib/matplotlib/widgets.py (revision 8149) +++ lib/matplotlib/widgets.py (working copy) @@ -1017,7 +1017,8 @@ """ def __init__(self, ax, onselect, drawtype='box', minspanx=None, minspany=None, useblit=False, - lineprops=None, rectprops=None, spancoords='data'): + lineprops=None, rectprops=None, spancoords='data', + useBtn=None): """ Create a selector in ax. When a selection is made, clear @@ -1047,6 +1048,15 @@ spancoords is one of 'data' or 'pixels'. If 'data', minspanx and minspanx will be interpreted in the same coordinates as the x and ya axis, if 'pixels', they are in pixels + +useBtn is a list of integers indicating which mouse buttons should +be used for rectangle selection. You can also specify a single +integer if only a single button is desired. Default is None, which +does not limit which button can be used. +Note, typically: + 1 = left mouse button + 2 = center mouse button (scroll wheel) + 3 = right mouse button """ self.ax = ax self.visible = True @@ -1084,6 +1094,11 @@ self.minspanx = minspanx self.minspany = minspany +if useBtn is None or isinstance(useBtn, list): +self.validButtons = useBtn +elif isinstance(useBtn, int): +self.validButtons = [useBtn] + assert(spancoords in ('data', 'pixels')) self.spancoords = spancoords @@ -1109,6 +1124,12 @@ if not self.canvas.widgetlock.available(self): return True +# Only do rectangle selection if event was triggered +# with a desired button +if self.validButtons is not None: +if not event.button in self.validButtons: +return True + # If no button was pressed yet ignore the event if it was out # of the axes if self.eventpress == None: Index: examples/widgets/rectangle_selector.py === --- examples/widgets/rectangle_selector.py (revision 8149) +++ examples/widgets/rectangle_selector.py (working copy) @@ -30,5 +30,6 @@ # drawtype is 'box' or 'line' or 'none' LS = RectangleSelector(current_ax, line_select_callback, drawtype='box',useblit=True, + useBtn = [1, 3], # don't use center mouse button minspanx=5,minspany=5,spancoords='pixels') show() -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] patch submission - rectangle selector button select
On Tue, Feb 23, 2010 at 10:22 AM, Ben Axelrod wrote: > Here is a patch for a new feature for the rectangle selector. it allows the > user to specify which mouse button or buttons to use for the rectangle > selection. Also included in the diff is a one line change to the > rectangle_selector example code to demonstrate the use of the feature. Thanks, committed this. Renamed "useBtn" to simply "button". JDH -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] SciPy2010 Call for Papers
== SciPy 2010 Call for Papers == SciPy 2010, the 9th Python in Science Conference, will be held from June 28th - July 3rd, 2010 in Austin, Texas. At this conference, novel applications and breakthroughs made in the pursuit of science using Python are presented. Attended by leading figures from both academia and industry, it is an excellent opportunity to experience the cutting edge of scientific software development. The conference is preceded by two days of paid tutorials, during which community experts provide training on several scientific Python packages. We invite you to take part by submitting a talk abstract on the conference website at: http://conference.scipy.org Talk/Paper Submission = We solicit talks and accompanying papers (either formal academic or magazine-style articles) that discuss topics regarding scientific computing using Python, including applications, teaching, development and research. Papers are included in the peer-reviewed conference proceedings, published online. Please note that submissions primarily aimed at the promotion of a commercial product or service will not be considered. Important dates for authors include: * 11 April: Talk abstracts due * 20 April: Notification of acceptance * 13 June: Papers due * 15 August: Publication of proceedings Further detail will be made available on http://conference.scipy.org Conference Dates * Friday, 10 May: Early registration ends * Monday-Tuesday, 28-29 June: Tutorials * Wednesday-Thursday, June 30-July 1: Conference * Friday-Saturday, July 2-3: Coding Sprints Executive Committee === * Conference: Jarrod Millman & Eric Jones * Program: Stefan van der Walt & Ondrej Certik * Student Sponsorship: Travis Oliphant For more information on Python, visit http://www.python.org. -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
Re: [matplotlib-devel] An easier way to create figure and group of axes; useful?
On Sat, Feb 20, 2010 at 3:50 PM, Jae-Joon Lee wrote: > > > After quickly going through the mpl source (and in my experience), I > think it is quite safe to assume that there is no master-slave > relation among the shared axes. > > >> One more, related question: is it possible/reasonable to share *both* >> x and y axes? > > Yes, it is possible as I often do. OK, thanks for the feedback. I've just finalized it here: http://gfif.udea.edu.co/idf/indefero/www/index.php/p/mscomp-2010/source/tree/master/0217/figsubp.py Knowing now that the sharing doesn't have an actual master/slave relationship (like the existing examples suggest since they appear to require an explicit index for sharing), the actual implementation was really trivial in the end. It might be a good idea to clarify this in the main docs, the current examples make axis sharing look harder than it actually is (all those tricks with order creation I was playing are completely unnecessary). If you all like this API, I'm happy to push into the real svn repo. Final question: should I put the little demo code at the bottom that I used for testing this up in an example file? I put some of that in the docstring as an example, but not all to avoid clutter. Cheers, f -- Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev ___ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel