Ignore:
Timestamp:
Apr 27, 2012 10:23:08 AM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
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
Message:

Pep-8-ification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plottools/src/danse/common/plottools/binder.py

    r0e553fd r10bfeb3  
    22Extension to MPL to support the binding of artists to key/mouse events. 
    33""" 
     4import sys 
     5 
    46 
    57class Selection: 
     
    1214    artist = None 
    1315    prop = {} 
     16     
    1417    def __init__(self, artist=None, prop={}): 
    1518        self.artist, self.prop = artist, self.prop 
     
    2326    def __nonzero__(self): 
    2427        return self.artist is not None 
     28 
    2529 
    2630class BindArtist: 
     
    6670            ] 
    6771             
    68  
    69         # Turn off picker if it hasn't already been done 
    70         #try: 
    71         #    canvas.mpl_disconnect(canvas.button_pick_id) 
    72         #    canvas.mpl_disconnect(canvas.scroll_pick_id) 
    73         #except:  
    74         #    pass 
    7572        self._current = None 
    7673        self._actions = {} 
     
    121118        In case we need to disconnect from the canvas... 
    122119        """ 
    123         try:  
     120        try: 
    124121            for cid in self._connections: self.canvas.mpl_disconnect(cid) 
    125         except:  
     122        except: 
     123            print "Error disconnection canvas: %s" % sys.exc_value 
    126124            pass 
    127125        self._connections = [] 
     
    165163            shift,control,alt,meta are flags which are true if the 
    166164                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 
    168166                id(s) of the point that were clicked. 
    169167                 
     
    182180        TODO: Attach multiple callbacks to the same event? 
    183181        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 
    185183             the duration 
    186184        TODO:   e.g., to support ? context sensitive help 
     
    193191        # Register the trigger callback 
    194192        self._actions[trigger][artist] = action 
    195         #print "==> added",artist,[artist],"to",trigger,":", 
    196         #self._actions[trigger].keys() 
    197193 
    198194        # Maintain a list of all artists 
    199         if artist not in self._artists:  
     195        if artist not in self._artists: 
    200196            self._artists.append(artist) 
    201197 
     
    239235        # TODO: sort by zorder of axes then by zorder within axes 
    240236        self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 
    241         # print "search"," ".join([str(h) for h in self._artists]) 
    242237        found = Selection() 
    243         #print "searching in",self._artists 
    244238        for artist in self._artists: 
    245239            # TODO: should contains() return false if invisible? 
    246             if not artist.get_visible():  
     240            if not artist.get_visible(): 
    247241                continue 
    248242            # TODO: optimization - exclude artists not inaxes 
     
    255249                found.artist, found.prop = artist, prop 
    256250                break 
    257         #print "found",found.artist 
    258251         
    259252        # TODO: how to check if prop is equal? 
     
    296289                x, y = transform.inverse_xy_tup((x, y)) 
    297290 
    298                 
    299291            event.xdata, event.ydata = x, y 
    300292            self.trigger(self._hasclick, 'drag', event) 
    301293        else: 
    302294            found = self._find_current(event) 
    303             #print "found",found.artist 
    304295            self.trigger(found, 'motion', event) 
    305296 
     
    312303        # Check for double-click 
    313304        event_time = time.time() 
    314         #print event_time,self._last_time,self.dclick_threshhold 
    315         #print (event_time > self._last_time + self.dclick_threshhold) 
    316         #print event.button,self._last_button 
    317305        if (event.button != self._last_button) or \ 
    318306                (event_time > self._last_time + self.dclick_threshhold): 
     
    376364        # TODO: Can we tab between items? 
    377365        # 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 
    379367        # TODO: architecture a la Tk? 
    380368        # TODO: Do modifiers cause a grab?  Does the artist see the modifiers? 
     
    408396        found = self._find_current(event) 
    409397        self.trigger(found, 'scroll', event) 
    410  
Note: See TracChangeset for help on using the changeset viewer.