def on_key_event(self, event): if event.key == 'a': ax = event.inaxes ax.set_autoscalex_on(True) ax.set_autoscaley_on(True) else: key_press_handler(event, self.canvas, self.toolbar)
def on_key_press(self, event): #绑定键盘事件到画布和工具栏 key_press_handler(event, self.canvas, self.toolbar) if event.key == "enter": self.data.get_homo() elif event.key == "N": self.emit(QtCore.SIGNAL("play_next()"))
def on_key_event(self, event): print('you pressed %s'%event.key) key_press_handler(event, self.canvas, self.toolbar) if event.key in ['q','escape']: # Use (some) unassigned buttons to quit print('--> Program quit') self.root.quit() self.root.destroy() # this is necessary on Windows to prevent
def on_key_press(self, event): from matplotlib.backend_bases import key_press_handler print("you pressed", event.key) # implement the default mpl key press events described at # http://matplotlib.org/users/navigation_toolbar.html key_press_handler(event, self.canvas, self.mpl_toolbar)
def on_key_event(self, event): """ @param event: @return """ print('you pressed %s' % event.key) key_press_handler(event, self.canvas, self.toolbar)
def on_key_press(self, event): print('Plot pressed', event.key) # implement the default mpl key press events described at # http://matplotlib.org/users/navigation_toolbar.html#navigation-keyboard-shortcuts try: key_press_handler(event, self.canvas, self.mpl_toolbar) except: pass
def on_key_press(self, event): if event.key == 'a' or event.key == "alt+a" and event.inaxes: ax = event.inaxes ax.relim() l = 1.1*max(abs(ax.dataLim.y0), abs(ax.dataLim.y1)) ax.set_ylim(-l,l) ax.figure.canvas.draw() else: key_press_handler(event, event.canvas, self.toolbar)
def on_key_press(self, event): # sometimes mpl has a weird ideas what oo-programing is. # any could overwrite method by my self # no fullscreen unless self is a window! if event.key == "t": self.toolbar.toggle() elif event.key not in rcParams["keymap.fullscreen"]: key_press_handler(event, self.canvas, self.toolbar)
def on_key_press(self, event): # print 'Matplotlib-> you pressed:' + str(event.key) # implement the default mpl key press events described at # http://matplotlib.org/users/navigation_toolbar.html#navigation- # keyboard-shortcuts try: from matplotlib.backend_bases import key_press_handler key_press_handler(event, self.canvas, self.mpl_toolbar) except: print("key_press_handler import failed. -old matplotlib version.")
def key_press(self, event): if event.key == 'escape': if self.toolbar._active is 'ZOOM': # if zoom is on, turn off self.toolbar.zoom() # turns zoom off elif self.toolbar._active is 'PAN': self.toolbar.pan() # elif event.key == 'shift': elif event.key == 'x': # Does nothing, would like to make sticky constraint zoom/pan self.x_zoom_constraint = not self.x_zoom_constraint elif event.key == 'y': # Does nothing, would like to make sticky constraint zoom/pan self.y_zoom_constraint = not self.y_zoom_constraint elif event.key in ['s', 'l', 'L', 'k']: pass else: key_press_handler(event, self.canvas, self.toolbar)
def canvas_key_press(self, event): key_press_handler(event, self.canvas, self.mpl_toolbar) if event.key == 'ctrl+q': self._close() elif event.key in mpl.rcParams['keymap.home']: self.xlim = self.ylim = None self.draw() elif event.key == 'ctrl+x': self.set_xlim(draw=False) elif event.key == 'ctrl+y': self.set_ylim(draw=False) elif event.key == 'ctrl+l': self.draw() self.xlogscale = self.axes.get_xscale() self.ylogscale = self.axes.get_yscale()
def on_key_press(self, event): key_press_handler(event, self.canvas, self.mpl_toolbar) if event.key == 'a': command = commands.AddIonsToTable([self._picked_ion], self._analyses_model) self._undo_stack.push(command) if event.key == 'r': command = commands.AddIonsToTable([self._picked_ion], self._analyses_model) self._undo_stack.push(command) command = commands.SelectMethod(self._picked_ion, 'Manual', self._analyses_model, self._methods_view_model) self._undo_stack.push(command) self._span_selector = SpanSelector(self.ax,self.on_span_select,'horizontal', minspan=0.0001, span_stays=True, rectprops=dict(alpha=0.5)) QApplication.setOverrideCursor(QCursor(Qt.IBeamCursor))
def on_key_event(event): print('you pressed %s' % event.key) if event.key == 'left': self.dataInd = max(self.dataInd - 2, -1) show_next() if event.key == 'right': show_next() if event.key == 'up': _same() if event.key == 'down': _differ() if event.key == 'space': _same() key_press_handler(event, canvas, toolbar)
def on_key_event(event): #Flecha de abajo if event.key == D: global state global a global b global x x = x if state == 5: state = 0 else: state = state + 1 graficar(x) #Flecha de arriba elif event.key == U: global state global a global b global x x = x if state == 0: state = 5 else: state = state - 1 graficar(x) #Flecha derecha elif event.key == R: global a global b global x if x >= 700: x = 700 else: x = x + 10 graficar(x) #Flecha Izquierda elif event.key == L: global a global b global x if x <= 200: x = 200 else: x = x - 10 graficar(x) else: pass key_press_handler(event, canvas, toolbar)
def on_key_event(event): #Flecha de abajo if event.key==D: global state global a global b global x x = x if state==5: state=0 else: state=state+1 graficar(x) #Flecha de arriba elif event.key==U: global state global a global b global x x = x if state==0: state=5 else: state=state-1 graficar(x) #Flecha derecha elif event.key==R: global a global b global x if x>=700: x=700 else: x = x + 10 graficar(x) #Flecha Izquierda elif event.key==L: global a global b global x if x<=200: x=200 else: x = x - 10 graficar(x) else: pass key_press_handler(event, canvas, toolbar)
def on_key_press(event): if event.key in ['ctrl+w', 'ctrl+q']: return self.quit() if event.key == 'ctrl+s': return self.save() if event.key == 'ctrl+o': return self.load() if event.key == 'ctrl+a': return self.resize_plot() if event.key == 'ctrl+c': return self.toggle_connection() if event.key == 'ctrl+r': return self.toggle_realtime() if event.key == 'ctrl+t': return self.get_storage() key_press_handler(event, canvas, self.toolbar)
def tracer_key_handler( self, event ) : if event.key == 'p' or event.key == ' ' : self.pause() elif event.key == 'b' : self.band() elif event.key == 'd' : self.save_data() elif event.key == 'a' : event.inaxes.abscissa.set_visible( not event.inaxes.abscissa.get_visible() ) self.canvas.draw() else : try : key_press_handler( event, self.canvas, self ) except NameError : pass
def render(self, latexfile=None): for ax in self.axes: self._axes_legend(ax) if latexfile is None: if HEADLESS_MODE: print("Warning: running in headless mode, won't show anything", file=sys.stdout) return win = tk.Tk() win.title('Figure') canvas = FigureCanvasTkAgg(self, master=win) canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True) toolbar = NavigationToolbar2Tk(canvas, win) toolbar.update() canvas.mpl_connect( 'key_press_event', lambda ev: key_press_handler(ev, canvas, toolbar)) canvas.draw() tk.mainloop() else: tikzcode = tikzplotlib.get_tikz_code( figure=self, extra_axis_parameters=[ 'scaled ticks=false', 'xticklabel style={/pgf/number format/.cd,fixed,precision=2}', 'yticklabel style={/pgf/number format/.cd,fixed,precision=2}' ], axis_width=r'\figW', float_format='.5g') with open(latexfile, 'w') as f: f.write(tikzcode)
def __init__(self, parent, price_book, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.price_book = price_book self.figure = Figure(figsize=(4, 4), dpi=100) self.sub_graph = self.figure.add_subplot(111) box = self.sub_graph.get_position() self.figure.subplots_adjust(left=0.05, right=0.84, bottom=0.05, top=0.96) self.book_url = {} self.force_update = False self.canvas = FigureCanvasTkAgg(self.figure, master=self) self.canvas.draw() self.canvas.get_tk_widget().pack(side='top', fill='both', expand=True) self.toolbar = NavigationToolbar2Tk(self.canvas, self) self.toolbar.update() self.canvas.get_tk_widget().pack(side='top', fill='both', expand=True) self.canvas.mpl_connect( "key_press_event", lambda event: key_press_handler(event, self.canvas, self.toolbar))
def keyPressEvent(self, event): """ Catch key events so that they can be passed on to the matplotlib toolbar. """ try: key_press_handler(event, self.canvas, self.toolbar) except AttributeError: # Attribute errors seem to occur when a key is pressed while the # mouse is outside of the figure area: # # AttributeError: 'QKeyEvent' object has no attribute 'inaxes' # # This exception may be safely ignored. pass except Exception as e: print(e) raise e
def on_key_event(event): global plotvar, planen, plotfile key_press_handler(event, canvas, toolbar) if (event.key == 'right'): if (plotfile.state()<(len(filelist)-1)): plotfile.v.set(plotfile.state()+1) else: plotfile.v.set(0) #print("Plotting: "+filelist[plotfile.state()]) _plotdata() if (event.key=='left'): if (plotfile.state()>0): plotfile.v.set(plotfile.state()-1) else: plotfile.v.set(len(filelist)-1) #print("Plotting: "+filelist[plotfile.state()]) _plotdata() if (event.key.upper()=='P'): print("Plotting data") _plotdata()
def __init__(self, parent): QtGui.QDialog.__init__( self, parent, QtCore.Qt.WindowMinMaxButtonsHint | QtCore.Qt.WindowCloseButtonHint) self.figure = MyFigure(self) self.canvas = FigureCanvas(self.figure) self.toolbar = NavigationToolbar(self.canvas, self) self.layout = QtGui.QGridLayout() self.setLayout(self.layout) layout = [ [self.toolbar], [self.canvas], ] for row_index, columns in enumerate(layout): if type(columns) is list: for column_index, widget in enumerate(columns): if widget is not None: self.layout.addWidget(widget, row_index, column_index) self.canvas.mpl_connect( 'key_press_event', lambda event: key_press_handler(event, self.canvas, self.toolbar))
def handle_key_press(event): if event.key == "q": window.quit() # stop the main loop window.destroy() # necessary on Windows to prevent fatal error elif event.key.isdigit(): toggle_ch(event) elif event.key == "h": print(hotkeys) elif event.key == " ": show_next_event() elif event.key == "b": show_previous_event() else: # handle default matplotlib key bindings from matplotlib.backend_bases import key_press_handler key_press_handler(event, canvas)
def tracer_key_handler(self, event): if event.key == 'p' or event.key == ' ': self.pause() elif event.key == 'b': self.band() elif event.key == 'd': self.save_data() elif event.key == 'a': event.inaxes.abscissa.set_visible( not event.inaxes.abscissa.get_visible()) self.canvas.draw() else: try: key_press_handler(event, self.canvas, self) except NameError: pass
def on_key(self,event): """to change scale from linear to logaritm Home/Reset h or r or home Back c or left arrow or backspace Forward v or right arrow Pan/Zoom p Zoom-to-rect o Save ctrl + s Toggle fullscreen ctrl + f Close plot ctrl + w Constrain pan/zoom to x axis hold x when panning/zooming with mouse Constrain pan/zoom to y axis hold y when panning/zooming with mouse Preserve aspect ratio hold CONTROL when panning/zooming with mouse Toggle grid g when mouse is over an axes Toggle x axis scale (log/linear) L or k when mouse is over an axes Toggle y axis scale (log/linear) l when mouse is over an axes """ key_press_handler(event, self.canvas, self.toolbar)
def on_key(self, event): """to change scale from linear to logaritm Home/Reset h or r or home Back c or left arrow or backspace Forward v or right arrow Pan/Zoom p Zoom-to-rect o Save ctrl + s Toggle fullscreen ctrl + f Close plot ctrl + w Constrain pan/zoom to x axis hold x when panning/zooming with mouse Constrain pan/zoom to y axis hold y when panning/zooming with mouse Preserve aspect ratio hold CONTROL when panning/zooming with mouse Toggle grid g when mouse is over an axes Toggle x axis scale (log/linear) L or k when mouse is over an axes Toggle y axis scale (log/linear) l when mouse is over an axes """ key_press_handler(event, self.canvas, self.toolbar)
def on_key_press(self, event): ''' 当按下回车键,计算一个H;按下SHift+n,处理下一副图像 ''' key_press_handler(event, self.canvas, self.toolBar)# 绑定mpl按键到画布和工具栏 if event.key is "enter": # 计算H if self.data.nCorner > 2: print("Compute H...") self.data.solve_homography() #print(self.data.nCorner + 1, self.data.corners) else: print("Not enough corners!") # 初始化单应的角点列表数据 self.data.init_corners() print(">>> click the cross point on same circle OR play next image.") elif event.key is "N": print(event.key) self.emit(QtCore.SIGNAL("play_next()"))
def _move_base_events(self, key, event): if key == self._mapbase.key_marker1: self._event_marker(self._marker1) elif key == self._mapbase.key_marker2: self._event_marker(self._marker2) elif key == self._mapbase.key_grid: self._event_grid() elif key == self._mapbase.key_linestyle: self._event_linestyle('-') elif key == self._mapbase.key_quit: self._event_quit() elif key == self._mapbase.key_quitall: self._event_quit( destroy_rootwindow=False if self._is_root else True) elif key == self._mapbase.key_toolbar: self._event_toolbar() else: key_press_handler(event, self._canvas, toolbar=self._toolbar)
def __init__(self, fig): import tkinter self.root = tkinter.Tk() self.canvas = FigureCanvasTkAgg(fig, master=self.root) toolbar = NavigationToolbar2Tk(self.canvas, self.root) self.canvas.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1) self.canvas.mpl_connect("key_press_event", lambda e: key_press_handler(e,self.canvas,toolbar)) button=tkinter.Button(master=self.root, text="Close and continue", command=self.quit) button.pack(side=tkinter.BOTTOM) self.root.mainloop()
def on_key_press(self, event): if event.key == 'i': if self.widget.mpl.ntb._active == 'PAN': self.widget.mpl.ntb.pan() if self.widget.mpl.ntb._active == 'ZOOM': self.widget.mpl.ntb.zoom() elif event.key == 's': self.session_ctrl.save_dpp_ppss() elif event.key == 'w': self.plot_new_graph() elif event.key == 'v': lims = self.widget.mpl.canvas.ax_pattern.axis() if self.widget.checkBox_BgSub.isChecked(): x, y = self.model.base_ptn.get_bgsub() else: x, y = self.model.base_ptn.get_raw() xroi, yroi = get_DataSection(x, y, [lims[0], lims[1]]) self.plot_ctrl.update([lims[0], lims[1], yroi.min(), yroi.max()]) else: key_press_handler(event, self.widget.mpl.canvas, self.widget.mpl.ntb)
def on_key_press(self, event): if event.key == 'i': print('* image infos:') print('shape is (%dx%d)' % (np.shape(self.data)[0], np.shape(self.data)[1])) print('min in image= %d, max in image=%d' % (np.min(self.data), np.max(self.data))) elif event.key == 'right': # load next image self.parent().parent().on_next_image() elif event.key == 'left': # load previous image self.parent().parent().on_prev_image() elif event.key == 'h': # plot the image histogram hist(self.data, data_range=(np.min(self.data), np.max(self.data)), show=True) # implement the default mpl key press events described at # http://matplotlib.org/users/navigation_toolbar.html#navigation-keyboard-shortcuts key_press_handler(event, self.canvas, self.mpl_toolbar)
def __init_fig_canvas(self, mother_frame): """ Creates a plotting area for matplotlib. Parameters ---------- mother_frame : ttk.Frame A frame to place the canvas in. """ self.fig = Fig() # Enlargended canvas to my preference self.fig_frame = ttk.Frame(mother_frame) self.fig_frame.pack(side='left', fill='both', expand='True') self.fig_canvas = FigureCanvasTkAgg( self.fig, master=self.fig_frame) self.fig_canvas.draw() self.fig_canvas.get_tk_widget().pack( side='left', fill='x', expand='True') fig_toolbar = NavigationToolbar2Tk(self.fig_canvas, self.fig_frame) fig_toolbar.update() ttk.Button(self.fig_frame, text='start processing', command=self.start_processing).pack(side='left') ttk.Button(self.fig_frame, text='start postprocessing', command=self.start_postprocessing).pack(side='left') ttk.Button(self.fig_frame, text='% invalid vectors', command=self.calculate_invalid_vectors).pack(side='left') self.progressbar = ttk.Progressbar(self.fig_frame, orient='horizontal', length=200, mode='indeterminate') self.progressbar.pack(side='right') self.process_type = ttk.Label(self.fig_frame, text=' ') self.process_type.pack(side='right') self.fig_canvas._tkcanvas.pack(side='top', fill='both', expand='True') self.fig_canvas.mpl_connect("key_press_event", lambda: key_press_handler(event, self.fig_canvas, fig_toolbar))
def draw(self, canvas_index=None): ''' Draw the current (or indicated) canvas. ''' if not canvas_index: canvas_index = self.current_tab # self.canvases[canvas_index].draw() ax = self.figs[canvas_index].axes mplcursors.cursor( ax, hover=2 ) # set plots so that hovering over generates a pop-up annotation, but goes away when mouse leaves on_key_press = lambda event, canvas=self.canvases[ canvas_index], tbar=self.toolbars[canvas_index]: key_press_handler( event, canvas, tbar) self.canvases[canvas_index].mpl_connect("key_press_event", on_key_press)
def on_key_press(event): print("you pressed {}".format(event.key)) key_press_handler(event, canvas, toolbar)
def on_key_event(event): key_press_handler(event, self._canvas, self._toolbar)
def on_key_press(self, event): print(event) key_press_handler(event, self.canvas, self.toolbar)
def on_key_press(event): key_press_handler(event, canvas, mpl_toolbar)
def on_key_event(event): print('you pressed %s' % event.key) key_press_handler(event, canvas, toolbar)
def on_key_event(self, event): print('you pressed %s'%event.key) key_press_handler(event, self.canvas, self.toolbar)
def on_key_event(event): # print('you pressed %s' % event.key) key_press_handler(event, self._canvas, self._toolbar)
def on_key_event(event): key_press_handler(event, canvas, toolbar)
def on_mouse_move(self, event): self.mouse_move.emit(event) key_press_handler(event, self.canvas, self.mpl_toolbar)
def on_button_press(self, event): self.button_pressed.emit(event) key_press_handler(event, self.canvas, self.mpl_toolbar)
def on_key_press(self, event): print('you pressed', event.key) key_press_handler(event, self.canvas, self.ntb)
def on_key_press(event): #Matplotlib Toolbar keybindings: key_press_handler(event, canvas, toolbar)
def on_key_press(event): if event.key == 'q': _quit() if event.key == 'c': output.get_tk_widget().destroy() key_press_handler(event, output)
def on_key_event(event): print('you pressed %s' % event.key) key_press_handler(event, canvas, toolbar) canvas.mpl_connect('key_press_event', on_key_event)
def on_key_event(event): if event.key in '1234560': update(event.key) key_press_handler(event, canvas, toolbar)
def on_key_press(self, event): key_press_handler(event, self.canvas, self.mpl_toolbar)
def on_key_press(self, event): print("you pressed {}".format(event.key)) key_press_handler(event, self.canvas, self.toolbar)
def on_key_event(event): print('you pressed %s'%event.key) key_press_handler(event, canvas, toolbar)
def on_key_event(event): print 'event is ', event key_press_handler(event, canvas, toolbar)
def on_key_press(event): key_press_handler(event, self.canvas, toolbar)
def on_key_press(self, event): print('you pressed', event.key) # implement the default mpl key press events described at # http://matplotlib.sourceforge.net/users/navigation_toolbar.html#navigation-keyboard-shortcuts key_press_handler(event, self.canvas, self.mpl_toolbar)