Ejemplo n.º 1
0
        def wrapper(widget, event):
            thisEvent = MplEvent(s, self) 

            thisEvent.x = event.x
            # flipy so y=0 is bottom of canvas
            thisEvent.y = self.figure.bbox.height() - event.y
 
            thisEvent.button = self._button
            thisEvent.key = self._key

            thisEvent.inaxes = None
            for a in self.figure.get_axes():
                if a.in_axes(thisEvent.x, thisEvent.y):
                    thisEvent.inaxes = a
                    xdata, ydata = a.transData.inverse_xy_tup((thisEvent.x, thisEvent.y))
                    thisEvent.xdata  = xdata
                    thisEvent.ydata  = ydata
                    break
                
            
            func(thisEvent)
            return False  # return True blocks other connects
Ejemplo n.º 2
0
def fltk_event2mpl_event(s,source, need_pos=False, need_button=False, need_key=False):
    special={Fltk.FL_Shift_R:'shift',
             Fltk.FL_Shift_L:'shift',
             Fltk.FL_Control_R:'control',
             Fltk.FL_Control_L:'control',
             Fltk.FL_Control_R:'control',
             Fltk.FL_Control_L:'control',
             65515:'win',    
             65516:'win',    
             }
                 
    thisEvent = MplEvent(s,source) 
    thisEvent.x = Fltk.Fl.event_x()
    # flipy so y=0 is bottom of canvas
    thisEvent.y = source.figure.bbox.height() - Fltk.Fl.event_y()
    if need_pos:  
        thisEvent.inaxes = None
        for a in source.figure.get_axes():
            if a.in_axes(thisEvent.x, thisEvent.y):
                thisEvent.inaxes = a
                xdata, ydata = a.transData.inverse_xy_tup((thisEvent.x, thisEvent.y))
                thisEvent.xdata  = xdata
                thisEvent.ydata  = ydata
                break
                
    if need_button:
        b1=Fltk.Fl.event_button1()
        b2=Fltk.Fl.event_button2()
        b3=Fltk.Fl.event_button3()
        thisEvent.button = None
        if b1:
         thisEvent.button = 1
        if b2:
         thisEvent.button = 2
        if b3:
         thisEvent.button = 3
    else:
        thisEvent.button = None
    
    ikey= Fltk.Fl.event_key()   
    if need_key and Fltk.Fl.event_key(ikey):  
        if(ikey<=255):
          thisEvent.key=chr(ikey)
        else:
          try:  
            thisEvent.key=special[ikey]   
          except:
            thisEvent.key=None  
    else:
        thisEvent.key=None
    return thisEvent  
Ejemplo n.º 3
0
def fltk_event2mpl_event(s,
                         source,
                         need_pos=False,
                         need_button=False,
                         need_key=False):
    special = {
        Fltk.FL_Shift_R: 'shift',
        Fltk.FL_Shift_L: 'shift',
        Fltk.FL_Control_R: 'control',
        Fltk.FL_Control_L: 'control',
        Fltk.FL_Control_R: 'control',
        Fltk.FL_Control_L: 'control',
        65515: 'win',
        65516: 'win',
    }

    thisEvent = MplEvent(s, source)
    thisEvent.x = Fltk.Fl.event_x()
    # flipy so y=0 is bottom of canvas
    thisEvent.y = source.figure.bbox.height() - Fltk.Fl.event_y()
    if need_pos:
        thisEvent.inaxes = None
        for a in source.figure.get_axes():
            if a.in_axes(thisEvent.x, thisEvent.y):
                thisEvent.inaxes = a
                xdata, ydata = a.transData.inverse_xy_tup(
                    (thisEvent.x, thisEvent.y))
                thisEvent.xdata = xdata
                thisEvent.ydata = ydata
                break

    if need_button:
        b1 = Fltk.Fl.event_button1()
        b2 = Fltk.Fl.event_button2()
        b3 = Fltk.Fl.event_button3()
        thisEvent.button = None
        if b1:
            thisEvent.button = 1
        if b2:
            thisEvent.button = 2
        if b3:
            thisEvent.button = 3
    else:
        thisEvent.button = None

    ikey = Fltk.Fl.event_key()
    if need_key and Fltk.Fl.event_key(ikey):
        if (ikey <= 255):
            thisEvent.key = chr(ikey)
        else:
            try:
                thisEvent.key = special[ikey]
            except:
                thisEvent.key = None
    else:
        thisEvent.key = None
    return thisEvent