Changeset 5251ec6 in sasview for src/sas/sasgui/plottools/binder.py
- Timestamp:
- Oct 11, 2018 2:20:56 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- 98b9f32
- Parents:
- 67ed543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/binder.py
r20fa5fe r5251ec6 28 28 return self.artist is not other.artist 29 29 30 def __ nonzero__(self):30 def __bool__(self): 31 31 return self.artist is not None 32 33 __nonzero__ = __bool__ 32 34 33 35 34 36 class BindArtist(object): 35 37 """ 38 Track keyboard modifiers for events. 36 39 """ 37 # Track keyboard modifiers for events.38 40 # TODO: Move keyboard modifier support into the backend. We cannot 39 41 # TODO: properly support it from outside the windowing system since there … … 65 67 ] 66 68 except: 67 print("bypassing scroll_event: wrong matplotlib version")69 logger.warn("bypassing scroll_event: wrong matplotlib version") 68 70 self._connections = [ 69 71 canvas.mpl_connect('motion_notify_event', self._onMotion), … … 74 76 ] 75 77 78 # Turn off picker if it hasn't already been done 79 try: 80 canvas.mpl_disconnect(canvas.button_pick_id) 81 canvas.mpl_disconnect(canvas.scroll_pick_id) 82 except Exception as exc: 83 logger.error(exc) 84 76 85 self._current = None 77 86 self._actions = {} … … 87 96 Use clearall() to reset all connections. 88 97 """ 89 90 98 for h in artists: 91 99 for a in self.events: … … 123 131 """ 124 132 try: 125 for cid in self._connections: self.canvas.mpl_disconnect(cid) 126 except: 127 logger.error("Error disconnection canvas: %s" % sys.exc_value) 133 for cid in self._connections: 134 self.canvas.mpl_disconnect(cid) 135 except Exception as exc: 136 logger.error("Error disconnection canvas: %s" % exc) 128 137 self._connections = [] 129 138 … … 172 181 sure it applies. E.g., the callback for 'press' might be: 173 182 if event.button == 1 and event.shift: process Shift-click 174 175 TODO: Only receive events with the correct modifiers (e.g., S-click, 176 TODO: or *-click for any modifiers). 177 TODO: Only receive button events for the correct button (e.g., click1 178 TODO: release3, or dclick* for any button) 179 TODO: Support virtual artist, so that and artist can be flagged as 180 TODO: having a tag list and receive the correct events 181 TODO: Support virtual events for binding to button-3 vs shift button-1 182 TODO: without changing callback code 183 TODO: Attach multiple callbacks to the same event? 184 TODO: Clean up interaction with toolbar modes 185 TODO: push/pushclear/pop context so that binding changes for 186 the duration 187 TODO: e.g., to support ? context sensitive help 188 """ 183 """ 184 #TODO: Only receive events with the correct modifiers (e.g., S-click, 185 #TODO: or *-click for any modifiers). 186 #TODO: Only receive button events for the correct button (e.g., click1 187 #TODO: release3, or dclick* for any button) 188 #TODO: Support virtual artist, so that and artist can be flagged as 189 #TODO: having a tag list and receive the correct events 190 #TODO: Support virtual events for binding to button-3 vs shift button-1 191 #TODO: without changing callback code 192 #TODO: Attach multiple callbacks to the same event? 193 #TODO: Clean up interaction with toolbar modes 194 #TODO: push/pushclear/pop context so that binding changes for the duration 195 #TODO: e.g., to support ? context sensitive help 196 189 197 # Check that the trigger is valid 190 198 if trigger not in self._actions: 191 raise ValueError , "%s invalid --- valid triggers are %s"\192 % (trigger, ", ".join(self.events))199 raise ValueError("%s invalid --- valid triggers are %s" 200 % (trigger, ", ".join(self.events))) 193 201 194 202 # Register the trigger callback … … 205 213 """ 206 214 if action not in self.events: 207 raise ValueError , "Trigger expects " + ", ".join(self.events)215 raise ValueError("Trigger expects " + ", ".join(self.events)) 208 216 209 217 # Tag the event with modifiers … … 214 222 setattr(ev, 'prop', {}) 215 223 216 # Fallback scheme. 224 # Fallback scheme. If the event does not return false, pass to parent. 217 225 processed = False 218 226 artist, prop = actor.artist, actor.prop … … 237 245 """ 238 246 # TODO: sort by zorder of axes then by zorder within axes 239 self._artists.sort( cmp=lambda x, y: cmp(y.zorder, x.zorder))247 self._artists.sort(key=lambda x: x.zorder, reverse=True) 240 248 found = Selection() 241 249 for artist in self._artists: … … 276 284 277 285 transform = self._hasclick.artist.get_transform() 278 # 286 #x,y = event.xdata,event.ydata 279 287 x, y = event.x, event.y 280 288 try: … … 286 294 # #transform ="CompositeGenericTransform" crash 287 295 pass 288 except: 289 # # CRUFT matplotlib-0.91 support 296 except: # CRUFT: matplotlib-0.91 support 290 297 # # exception for transform ="CompositeGenericTransform" 291 298 # # crashes also here 292 299 x, y = transform.inverse_xy_tup((x, y)) 293 300 294 # event.xdata, event.ydata = x, y 301 #TODO: why compute (x,y) if it isn't being used? 302 #event.xdata, event.ydata = x, y 295 303 self.trigger(self._hasclick, 'drag', event) 296 304 else:
Note: See TracChangeset
for help on using the changeset viewer.