SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(10)
2
(6)
3
4
(10)
5
(5)
6
(5)
7
(6)
8
(2)
9
(5)
10
(7)
11
(5)
12
(8)
13
(5)
14
(7)
15
(3)
16
(1)
17
(1)
18
19
(1)
20
(6)
21
(6)
22
(3)
23
(3)
24
(7)
25
26
(5)
27
(1)
28
(3)
29
(2)
30
(3)



Showing 1 results of 1

From: <ef...@us...> - 2010年06月19日 23:46:53
Revision: 8441
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8441&view=rev
Author: efiring
Date: 2010年06月19日 23:46:47 +0000 (2010年6月19日)
Log Message:
-----------
[1530104, 3017380] slider grabs mouse; patch by C. Gohlke and baxissimo
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backend_bases.py
 trunk/matplotlib/lib/matplotlib/widgets.py
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年06月17日 17:45:38 UTC (rev 8440)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py	2010年06月19日 23:46:47 UTC (rev 8441)
@@ -1122,7 +1122,10 @@
 return
 
 # Find all axes containing the mouse
- axes_list = [a for a in self.canvas.figure.get_axes() if a.in_axes(self)]
+ if self.canvas.mouse_grabber is None:
+ axes_list = [a for a in self.canvas.figure.get_axes() if a.in_axes(self)]
+ else:
+ axes_list = [self.canvas.mouse_grabber]
 
 if len(axes_list) == 0: # None found
 self.inaxes = None
@@ -1332,6 +1335,7 @@
 self._lastx, self._lasty = None, None
 self.button_pick_id = self.mpl_connect('button_press_event',self.pick)
 self.scroll_pick_id = self.mpl_connect('scroll_event',self.pick)
+ self.mouse_grabber = None # the axes currently grabbing mouse
 
 if False:
 ## highlight the artists that are hit
@@ -1610,6 +1614,26 @@
 event = IdleEvent(s, self, guiEvent=guiEvent)
 self.callbacks.process(s, event)
 
+ def grab_mouse(self, ax):
+ """
+ Set the child axes which are currently grabbing the mouse events.
+ Usually called by the widgets themselves.
+ It is an error to call this if the mouse is already grabbed by
+ another axes.
+ """
+ if self.mouse_grabber not in (None, ax):
+ raise RuntimeError('two different attempted to grab mouse input')
+ self.mouse_grabber = ax
+
+ def release_mouse(self, ax):
+ """
+ Release the mouse grab held by the axes, ax.
+ Usually called by the widgets.
+ It is ok to call this even if you ax doesn't have the mouse grab currently.
+ """
+ if self.mouse_grabber is ax:
+ self.mouse_grabber = None
+
 def draw(self, *args, **kwargs):
 """
 Render the :class:`~matplotlib.figure.Figure`
Modified: trunk/matplotlib/lib/matplotlib/widgets.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/widgets.py	2010年06月17日 17:45:38 UTC (rev 8440)
+++ trunk/matplotlib/lib/matplotlib/widgets.py	2010年06月19日 23:46:47 UTC (rev 8441)
@@ -106,6 +106,7 @@
 
 
 ax.figure.canvas.mpl_connect('button_press_event', self._click)
+ ax.figure.canvas.mpl_connect('button_release_event', self._release)
 ax.figure.canvas.mpl_connect('motion_notify_event', self._motion)
 ax.set_navigate(False)
 ax.set_axis_bgcolor(color)
@@ -117,8 +118,21 @@
 self._lastcolor = color
 
 def _click(self, event):
- if event.inaxes != self.ax: return
- if not self.eventson: return
+ if event.inaxes != self.ax:
+ return
+ if not self.eventson:
+ return
+ if event.canvas.mouse_grabber != self.ax:
+ event.canvas.grab_mouse(self.ax)
+
+ def _release(self, event):
+ if event.canvas.mouse_grabber != self.ax:
+ return
+ event.canvas.release_mouse(self.ax)
+ if not self.eventson:
+ return
+ if event.inaxes != self.ax: 
+ return
 for cid, func in self.observers.items():
 func(event)
 
@@ -209,6 +223,7 @@
 ax.set_navigate(False)
 
 ax.figure.canvas.mpl_connect('button_press_event', self._update)
+ ax.figure.canvas.mpl_connect('button_release_event', self._update)
 if dragging:
 ax.figure.canvas.mpl_connect('motion_notify_event', self._update)
 self.label = ax.text(-0.02, 0.5, label, transform=ax.transAxes,
@@ -227,14 +242,35 @@
 self.closedmax = closedmax
 self.slidermin = slidermin
 self.slidermax = slidermax
+ self.drag_active = False
 
 def _update(self, event):
 'update the slider position'
- if event.button !=1: return
- if event.inaxes != self.ax: return
+ if event.button != 1:
+ return
+
+ if event.name == 'button_press_event' and event.inaxes == self.ax:
+ self.drag_active = True
+ event.canvas.grab_mouse(self.ax)
+
+ if not self.drag_active: 
+ return
+ 
+ elif ((event.name == 'button_release_event') 
+ or (event.name == 'button_press_event' and event.inaxes != self.ax)):
+ self.drag_active = False
+ event.canvas.release_mouse(self.ax)
+ return
+
 val = event.xdata
- if not self.closedmin and val<=self.valmin: return
- if not self.closedmax and val>=self.valmax: return
+ if val <= self.valmin:
+ if not self.closedmin:
+ return
+ val = self.valmin
+ elif val >= self.valmax:
+ if not self.closedmax:
+ return
+ val = self.valmax
 
 if self.slidermin is not None:
 if val<=self.slidermin.val: return
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 1 results of 1

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /