Changeset 10bfeb3 in sasview for plottools/src/danse/common/plottools/binder.py
- Timestamp:
- Apr 27, 2012 10:23:08 AM (12 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- f60a8c2
- Parents:
- 8a621ac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plottools/src/danse/common/plottools/binder.py
r0e553fd r10bfeb3 2 2 Extension to MPL to support the binding of artists to key/mouse events. 3 3 """ 4 import sys 5 4 6 5 7 class Selection: … … 12 14 artist = None 13 15 prop = {} 16 14 17 def __init__(self, artist=None, prop={}): 15 18 self.artist, self.prop = artist, self.prop … … 23 26 def __nonzero__(self): 24 27 return self.artist is not None 28 25 29 26 30 class BindArtist: … … 66 70 ] 67 71 68 69 # Turn off picker if it hasn't already been done70 #try:71 # canvas.mpl_disconnect(canvas.button_pick_id)72 # canvas.mpl_disconnect(canvas.scroll_pick_id)73 #except:74 # pass75 72 self._current = None 76 73 self._actions = {} … … 121 118 In case we need to disconnect from the canvas... 122 119 """ 123 try: 120 try: 124 121 for cid in self._connections: self.canvas.mpl_disconnect(cid) 125 except: 122 except: 123 print "Error disconnection canvas: %s" % sys.exc_value 126 124 pass 127 125 self._connections = [] … … 165 163 shift,control,alt,meta are flags which are true if the 166 164 corresponding key is pressed at the time of the event. 167 details is a dictionary of artist specific details, such as the 165 details is a dictionary of artist specific details, such as the 168 166 id(s) of the point that were clicked. 169 167 … … 182 180 TODO: Attach multiple callbacks to the same event? 183 181 TODO: Clean up interaction with toolbar modes 184 TODO: push/pushclear/pop context so that binding changes for 182 TODO: push/pushclear/pop context so that binding changes for 185 183 the duration 186 184 TODO: e.g., to support ? context sensitive help … … 193 191 # Register the trigger callback 194 192 self._actions[trigger][artist] = action 195 #print "==> added",artist,[artist],"to",trigger,":",196 #self._actions[trigger].keys()197 193 198 194 # Maintain a list of all artists 199 if artist not in self._artists: 195 if artist not in self._artists: 200 196 self._artists.append(artist) 201 197 … … 239 235 # TODO: sort by zorder of axes then by zorder within axes 240 236 self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 241 # print "search"," ".join([str(h) for h in self._artists])242 237 found = Selection() 243 #print "searching in",self._artists244 238 for artist in self._artists: 245 239 # TODO: should contains() return false if invisible? 246 if not artist.get_visible(): 240 if not artist.get_visible(): 247 241 continue 248 242 # TODO: optimization - exclude artists not inaxes … … 255 249 found.artist, found.prop = artist, prop 256 250 break 257 #print "found",found.artist258 251 259 252 # TODO: how to check if prop is equal? … … 296 289 x, y = transform.inverse_xy_tup((x, y)) 297 290 298 299 291 event.xdata, event.ydata = x, y 300 292 self.trigger(self._hasclick, 'drag', event) 301 293 else: 302 294 found = self._find_current(event) 303 #print "found",found.artist304 295 self.trigger(found, 'motion', event) 305 296 … … 312 303 # Check for double-click 313 304 event_time = time.time() 314 #print event_time,self._last_time,self.dclick_threshhold315 #print (event_time > self._last_time + self.dclick_threshhold)316 #print event.button,self._last_button317 305 if (event.button != self._last_button) or \ 318 306 (event_time > self._last_time + self.dclick_threshhold): … … 376 364 # TODO: Can we tab between items? 377 365 # TODO: How do unhandled events get propogated to axes, figure and 378 # TODO: finally to application? Do we need to implement a full tags 366 # TODO: finally to application? Do we need to implement a full tags 379 367 # TODO: architecture a la Tk? 380 368 # TODO: Do modifiers cause a grab? Does the artist see the modifiers? … … 408 396 found = self._find_current(event) 409 397 self.trigger(found, 'scroll', event) 410
Note: See TracChangeset
for help on using the changeset viewer.