FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

From ed4d33858ba5950111e7dc18568695104fb61ab0 Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Mon, 23 Apr 2012 17:39:32 +0100 Subject: [PATCH 01/12] added a quit shortcut key for gui backends and fixed "toggle full screen" shortcut key which was broken. --- lib/matplotlib/backend_bases.py | 13 ++++++++----- lib/matplotlib/backends/backend_gtk.py | 2 +- lib/matplotlib/backends/backend_tkagg.py | 17 +++++++++-------- lib/matplotlib/rcsetup.py | 1 + matplotlibrc.template | 1 + 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 7dc841db4aa4..0c904c53aaf6 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2274,9 +2274,6 @@ def key_press_handler(event, canvas, toolbar=None): """ # these bindings happen whether you are over an axes or not - #if event.key == 'q': - # self.destroy() # how cruel to have to destroy oneself! - # return if event.key is None: return @@ -2289,6 +2286,7 @@ def key_press_handler(event, canvas, toolbar=None): pan_keys = rcParams['keymap.pan'] zoom_keys = rcParams['keymap.zoom'] save_keys = rcParams['keymap.save'] + quit_keys = rcParams['keymap.quit'] grid_keys = rcParams['keymap.grid'] toggle_yscale_keys = rcParams['keymap.yscale'] toggle_xscale_keys = rcParams['keymap.xscale'] @@ -2298,6 +2296,10 @@ def key_press_handler(event, canvas, toolbar=None): if event.key in fullscreen_keys: canvas.manager.full_screen_toggle() + # quit the figure (defaut key 'q') + if event.key in quit_keys: + Gcf.destroy_fig(canvas.figure) + if toolbar is not None: # home or reset mnemonic (default key 'h', 'home' and 'r') if event.key in home_keys: @@ -2322,7 +2324,8 @@ def key_press_handler(event, canvas, toolbar=None): if event.inaxes is None: return - # the mouse has to be over an axes to trigger these + # these bindings require the mouse to be over an axes to trigger + # switching on/off a grid in current axes (default key 'g') if event.key in grid_keys: event.inaxes.grid() @@ -2387,7 +2390,7 @@ def __init__(self, canvas, num): def destroy(self): pass - def full_screen_toggle (self): + def full_screen_toggle(self): pass def resize(self, w, h): diff --git a/lib/matplotlib/backends/backend_gtk.py b/lib/matplotlib/backends/backend_gtk.py index e4f6f31742f1..a96d5a5cbaf0 100644 --- a/lib/matplotlib/backends/backend_gtk.py +++ b/lib/matplotlib/backends/backend_gtk.py @@ -592,7 +592,7 @@ def show(self): # show the figure window self.window.show() - def full_screen_toggle (self): + def full_screen_toggle(self): self._full_screen_flag = not self._full_screen_flag if self._full_screen_flag: self.window.fullscreen() diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index 8a78a44a9d81..1ee78a9a7b71 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -457,7 +457,7 @@ def __init__(self, canvas, num, window): self.window.wm_title("Figure %d" % num) self.canvas = canvas self._num = num - t1,t2,w,h = canvas.figure.bbox.bounds + _, _, w, h = canvas.figure.bbox.bounds w, h = int(w), int(h) self.window.minsize(int(w*3/4),int(h*3/4)) if matplotlib.rcParams['toolbar']=='classic': @@ -476,12 +476,9 @@ def notify_axes_change(fig): if self.toolbar != None: self.toolbar.update() self.canvas.figure.add_axobserver(notify_axes_change) - - # attach a show method to the figure for pylab ease of use self.canvas.figure.show = lambda *args: self.show() - def resize(self, width, height=None): # before 09-12-22, the resize method takes a single *event* # parameter. On the other hand, the resize method of other @@ -499,7 +496,6 @@ def resize(self, width, height=None): self.toolbar.configure(width=width) - def show(self): """ this function doesn't segfault but causes the @@ -518,7 +514,6 @@ def destroy(*args): self.canvas.draw_idle() self._shown = True - def destroy(self, *args): if self.window is not None: #self.toolbar.destroy() @@ -533,6 +528,12 @@ def destroy(self, *args): def set_window_title(self, title): self.window.wm_title(title) + def full_screen_toggle(self): + # cross platform way of maximizing a tk window + # http://devourer09.blogspot.co.uk/2009/07/maximizing-tkinter-app.html + self.window.attributes('-zoomed', '1') + + class AxisMenu: def __init__(self, master, naxes): self._master = master @@ -597,7 +598,7 @@ def select_all(self): class NavigationToolbar(Tk.Frame): """ - Public attriubutes + Public attributes canvas - the FigureCanvas (gtk.DrawingArea) win - the gtk.Window @@ -722,7 +723,7 @@ def update(self): class NavigationToolbar2TkAgg(NavigationToolbar2, Tk.Frame): """ - Public attriubutes + Public attributes canvas - the FigureCanvas (gtk.DrawingArea) win - the gtk.Window diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 6df1d4b081f2..17e7ea0729f8 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -582,6 +582,7 @@ def __call__(self, s): 'keymap.pan' : ['p', validate_stringlist], 'keymap.zoom' : ['o', validate_stringlist], 'keymap.save' : ['s', validate_stringlist], + 'keymap.quit' : ['q', validate_stringlist], 'keymap.grid' : ['g', validate_stringlist], 'keymap.yscale' : ['l', validate_stringlist], 'keymap.xscale' : [['k', 'L'], validate_stringlist], diff --git a/matplotlibrc.template b/matplotlibrc.template index 6ebaac28bae3..16f2657f5026 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -410,6 +410,7 @@ text.hinting_factor : 8 # Specifies the amount of softness for hinting in the #keymap.pan : p # pan mnemonic #keymap.zoom : o # zoom mnemonic #keymap.save : s # saving current figure +#keymap.quit : q # close the current figure #keymap.grid : g # switching on/off a grid in current axes #keymap.yscale : l # toggle scaling of y-axes ('log'/'linear') #keymap.xscale : L, k # toggle scaling of x-axes ('log'/'linear') From c887139224ac30ceb2c77d249acf80da8ac9713e Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Mon, 23 Apr 2012 18:25:34 +0100 Subject: [PATCH 02/12] Backend factorisation for tooltip sharing. --- lib/matplotlib/backend_bases.py | 20 +++++ lib/matplotlib/backends/backend_gtk.py | 15 +--- lib/matplotlib/backends/backend_gtk3.py | 15 +--- lib/matplotlib/backends/backend_qt.py | 18 +--- lib/matplotlib/backends/backend_qt4.py | 25 ++---- lib/matplotlib/backends/backend_tkagg.py | 107 ++++++++++++++++------- 6 files changed, 107 insertions(+), 93 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 0c904c53aaf6..eb9b0e14c2b3 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -2467,6 +2467,26 @@ class NavigationToolbar2(object): That's it, we'll do the rest! """ + + # list of toolitems to add to the toolbar, format is: + # ( + # text, # the text of the button (often not visible to users) + # tooltip_text, # the tooltip shown on hover (where possible) + # image_file, # name of the image for the button (without the extension) + # name_of_method, # name of the method in NavigationToolbar2 to call + # ) + toolitems = ( + ('Home', 'Reset original view', 'home', 'home'), + ('Back', 'Back to previous view', 'back', 'back'), + ('Forward', 'Forward to next view', 'forward', 'forward'), + (None, None, None, None), + ('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'), + ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'), + (None, None, None, None), + ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'), + ('Save', 'Save the figure', 'filesave', 'save_figure'), + ) + def __init__(self, canvas): self.canvas = canvas diff --git a/lib/matplotlib/backends/backend_gtk.py b/lib/matplotlib/backends/backend_gtk.py index a96d5a5cbaf0..9ec97b64dc89 100644 --- a/lib/matplotlib/backends/backend_gtk.py +++ b/lib/matplotlib/backends/backend_gtk.py @@ -624,19 +624,6 @@ def resize(self, width, height): class NavigationToolbar2GTK(NavigationToolbar2, gtk.Toolbar): - # list of toolitems to add to the toolbar, format is: - # text, tooltip_text, image_file, callback(str) - toolitems = ( - ('Home', 'Reset original view', 'home.png', 'home'), - ('Back', 'Back to previous view','back.png', 'back'), - ('Forward', 'Forward to next view','forward.png', 'forward'), - ('Pan', 'Pan axes with left mouse, zoom with right', 'move.png','pan'), - ('Zoom', 'Zoom to rectangle','zoom_to_rect.png', 'zoom'), - (None, None, None, None), - ('Subplots', 'Configure subplots','subplots.png', 'configure_subplots'), - ('Save', 'Save the figure','filesave.png', 'save_figure'), - ) - def __init__(self, canvas, window): self.win = window gtk.Toolbar.__init__(self) @@ -704,7 +691,7 @@ def _init_toolbar2_4(self): if text is None: self.insert( gtk.SeparatorToolItem(), -1 ) continue - fname = os.path.join(basedir, image_file) + fname = os.path.join(basedir, image_file + '.png') image = gtk.Image() image.set_from_file(fname) tbutton = gtk.ToolButton(image, text) diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index b89564639789..a69cbcfff316 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -453,19 +453,6 @@ def resize(self, width, height): class NavigationToolbar2GTK3(NavigationToolbar2, Gtk.Toolbar): - # list of toolitems to add to the toolbar, format is: - # text, tooltip_text, image_file, callback(str) - toolitems = ( - ('Home', 'Reset original view', 'home.png', 'home'), - ('Back', 'Back to previous view','back.png', 'back'), - ('Forward', 'Forward to next view','forward.png', 'forward'), - ('Pan', 'Pan axes with left mouse, zoom with right', 'move.png','pan'), - ('Zoom', 'Zoom to rectangle','zoom_to_rect.png', 'zoom'), - (None, None, None, None), - ('Subplots', 'Configure subplots','subplots.png', 'configure_subplots'), - ('Save', 'Save the figure','filesave.png', 'save_figure'), - ) - def __init__(self, canvas, window): self.win = window GObject.GObject.__init__(self) @@ -516,7 +503,7 @@ def _init_toolbar(self): if text is None: self.insert( Gtk.SeparatorToolItem(), -1 ) continue - fname = os.path.join(basedir, image_file) + fname = os.path.join(basedir, image_file + '.png') image = Gtk.Image() image.set_from_file(fname) tbutton = Gtk.ToolButton() diff --git a/lib/matplotlib/backends/backend_qt.py b/lib/matplotlib/backends/backend_qt.py index 343bb3f033c1..21ab5fd4614a 100644 --- a/lib/matplotlib/backends/backend_qt.py +++ b/lib/matplotlib/backends/backend_qt.py @@ -295,20 +295,6 @@ def set_window_title(self, title): self.window.setCaption(title) class NavigationToolbar2QT( NavigationToolbar2, qt.QWidget ): - # list of toolitems to add to the toolbar, format is: - # text, tooltip_text, image_file, callback(str) - toolitems = ( - ('Home', 'Reset original view', 'home.ppm', 'home'), - ('Back', 'Back to previous view','back.ppm', 'back'), - ('Forward', 'Forward to next view','forward.ppm', 'forward'), - (None, None, None, None), - ('Pan', 'Pan axes with left mouse, zoom with right', 'move.ppm', 'pan'), - ('Zoom', 'Zoom to rectangle','zoom_to_rect.ppm', 'zoom'), - (None, None, None, None), - ('Subplots', 'Configure subplots','subplots.png', 'configure_subplots'), - ('Save', 'Save the figure','filesave.ppm', 'save_figure'), - ) - def __init__( self, canvas, parent ): self.canvas = canvas self.buttons = {} @@ -329,8 +315,8 @@ def _init_toolbar( self ): self.layout.addSpacing( 8 ) continue - fname = os.path.join( basedir, image_file ) - image = qt.QPixmap() + fname = os.path.join(basedir, image_file + '.ppm') + image = qt.QPixmap() image.load( fname ) button = qt.QPushButton( qt.QIconSet( image ), "", self ) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index b05138713fa2..1771503b954a 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -441,22 +441,15 @@ def _icon(self, name): def _init_toolbar(self): self.basedir = os.path.join(matplotlib.rcParams[ 'datapath' ],'images') - a = self.addAction(self._icon('home.png'), 'Home', self.home) - a.setToolTip('Reset original view') - a = self.addAction(self._icon('back.png'), 'Back', self.back) - a.setToolTip('Back to previous view') - a = self.addAction(self._icon('forward.png'), 'Forward', self.forward) - a.setToolTip('Forward to next view') - self.addSeparator() - a = self.addAction(self._icon('move.png'), 'Pan', self.pan) - a.setToolTip('Pan axes with left mouse, zoom with right') - a = self.addAction(self._icon('zoom_to_rect.png'), 'Zoom', self.zoom) - a.setToolTip('Zoom to rectangle') - self.addSeparator() - a = self.addAction(self._icon('subplots.png'), 'Subplots', - self.configure_subplots) - a.setToolTip('Configure subplots') - + # XXX pelson: use NavigationToolbar2.toolitems + for text, tooltip_text, image_file, callback in self.toolitems: + if text is None: + self.addSeparator() + else: + a = self.addAction(self._icon(image_file + '.png'), text, getattr(self, callback)) + if tooltip_text is not None: + a.setToolTip(tooltip_text) + if figureoptions is not None: a = self.addAction(self._icon("qt4_editor_options.png"), 'Customize', self.edit_parameters) diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index 1ee78a9a7b71..0862f77ec5b2 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -596,6 +596,7 @@ def select_all(self): a.set(1) self.set_active() + class NavigationToolbar(Tk.Frame): """ Public attributes @@ -626,39 +627,39 @@ def __init__(self, canvas, window): self.update() # Make axes menu self.bLeft = self._Button( - text="Left", file="stock_left.ppm", + text="Left", file="stock_left", command=lambda x=-1: self.panx(x)) self.bRight = self._Button( - text="Right", file="stock_right.ppm", + text="Right", file="stock_right", command=lambda x=1: self.panx(x)) self.bZoomInX = self._Button( - text="ZoomInX",file="stock_zoom-in.ppm", + text="ZoomInX",file="stock_zoom-in", command=lambda x=1: self.zoomx(x)) self.bZoomOutX = self._Button( - text="ZoomOutX", file="stock_zoom-out.ppm", + text="ZoomOutX", file="stock_zoom-out", command=lambda x=-1: self.zoomx(x)) self.bUp = self._Button( - text="Up", file="stock_up.ppm", + text="Up", file="stock_up", command=lambda y=1: self.pany(y)) self.bDown = self._Button( - text="Down", file="stock_down.ppm", + text="Down", file="stock_down", command=lambda y=-1: self.pany(y)) self.bZoomInY = self._Button( - text="ZoomInY", file="stock_zoom-in.ppm", + text="ZoomInY", file="stock_zoom-in", command=lambda y=1: self.zoomy(y)) self.bZoomOutY = self._Button( - text="ZoomOutY",file="stock_zoom-out.ppm", + text="ZoomOutY",file="stock_zoom-out", command=lambda y=-1: self.zoomy(y)) self.bSave = self._Button( - text="Save", file="stock_save_as.ppm", + text="Save", file="stock_save_as", command=self.save_figure) self.pack(side=Tk.BOTTOM, fill=Tk.X) @@ -763,9 +764,9 @@ def release(self, event): def set_cursor(self, cursor): self.window.configure(cursor=cursord[cursor]) - def _Button(self, text, file, command): - file = os.path.join(rcParams['datapath'], 'images', file) - im = Tk.PhotoImage(master=self, file=file) + def _Button(self, text, file, command, extension='.ppm'): + img_file = os.path.join(rcParams['datapath'], 'images', file + extension) + im = Tk.PhotoImage(master=self, file=img_file) b = Tk.Button( master=self, text=text, padx=2, pady=2, image=im, command=command) b._ntimage = im @@ -781,27 +782,16 @@ def _init_toolbar(self): self.update() # Make axes menu - self.bHome = self._Button( text="Home", file="home.ppm", - command=self.home) - - self.bBack = self._Button( text="Back", file="back.ppm", - command = self.back) - - self.bForward = self._Button(text="Forward", file="forward.ppm", - command = self.forward) - - self.bPan = self._Button( text="Pan", file="move.ppm", - command = self.pan) - - self.bZoom = self._Button( text="Zoom", - file="zoom_to_rect.ppm", - command = self.zoom) - - self.bsubplot = self._Button( text="Configure Subplots", file="subplots.ppm", - command = self.configure_subplots) - - self.bsave = self._Button( text="Save", file="filesave.ppm", - command = self.save_figure) + for text, tooltip_text, image_file, callback in self.toolitems: + if text is None: + # spacer, unhandled in Tk + pass + else: + button = self._Button(text=text, file=image_file, + command=getattr(self, callback)) + if tooltip_text is not None: + ToolTip.createToolTip(button, tooltip_text) + self.message = Tk.StringVar(master=self) self._message_label = Tk.Label(master=self, textvariable=self.message) self._message_label.pack(side=Tk.RIGHT) @@ -879,3 +869,54 @@ def dynamic_update(self): FigureManager = FigureManagerTkAgg + + +class ToolTip(object): + """ + Tooltip recipe from + http://www.voidspace.org.uk/python/weblog/arch_d7_2006_07_01.shtml#e387 + """ + @staticmethod + def createToolTip(widget, text): + toolTip = ToolTip(widget) + def enter(event): + toolTip.showtip(text) + def leave(event): + toolTip.hidetip() + widget.bind('', enter) + widget.bind('', leave) + + def __init__(self, widget): + self.widget = widget + self.tipwindow = None + self.id = None + self.x = self.y = 0 + + def showtip(self, text): + "Display text in tooltip window" + self.text = text + if self.tipwindow or not self.text: + return + x, y, _, _ = self.widget.bbox("insert") + x = x + self.widget.winfo_rootx() + 27 + y = y + self.widget.winfo_rooty() + self.tipwindow = tw = Tk.Toplevel(self.widget) + tw.wm_overrideredirect(1) + tw.wm_geometry("+%d+%d" % (x, y)) + try: + # For Mac OS + tw.tk.call("::tk::unsupported::MacWindowStyle", + "style", tw._w, + "help", "noActivates") + except Tk.TclError: + pass + label = Tk.Label(tw, text=self.text, justify=Tk.LEFT, + background="#ffffe0", relief=Tk.SOLID, borderwidth=1, + ) + label.pack(ipadx=1) + + def hidetip(self): + tw = self.tipwindow + self.tipwindow = None + if tw: + tw.destroy() \ No newline at end of file From 507e9aa75223261ca0c141056bda0ef109854f1a Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Mon, 23 Apr 2012 18:30:17 +0100 Subject: [PATCH 03/12] removed todo --- lib/matplotlib/backends/backend_qt4.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 1771503b954a..f2db06e518c6 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -441,7 +441,6 @@ def _icon(self, name): def _init_toolbar(self): self.basedir = os.path.join(matplotlib.rcParams[ 'datapath' ],'images') - # XXX pelson: use NavigationToolbar2.toolitems for text, tooltip_text, image_file, callback in self.toolitems: if text is None: self.addSeparator() From dc77096c23d7ee153c712d63d07dfa16be645ae0 Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Mon, 23 Apr 2012 23:04:03 +0100 Subject: [PATCH 04/12] Fullscreen rather than maximize in Tk. Added fullscreen support to qt4 backend. --- lib/matplotlib/backends/backend_qt4.py | 7 ++++++- lib/matplotlib/backends/backend_tkagg.py | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index f2db06e518c6..d5d739aded2d 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -383,6 +383,12 @@ def _show_message(self,s): # Fixes a PySide segfault. self.window.statusBar().showMessage(s) + def full_screen_toggle(self): + if self.window.isFullScreen(): + self.window.showNormal() + else: + self.window.showFullScreen() + def _widgetclosed( self ): if self.window._destroying: return self.window._destroying = True @@ -394,7 +400,6 @@ def _widgetclosed( self ): # Gcf can get destroyed before the Gcf.destroy # line is run, leading to a useless AttributeError. - def _get_toolbar(self, canvas, parent): # must be inited after the window, drawingArea and figure # attrs are set diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index 0862f77ec5b2..64aeae19123f 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -529,9 +529,8 @@ def set_window_title(self, title): self.window.wm_title(title) def full_screen_toggle(self): - # cross platform way of maximizing a tk window - # http://devourer09.blogspot.co.uk/2009/07/maximizing-tkinter-app.html - self.window.attributes('-zoomed', '1') + is_fullscreen = bool(self.window.attributes('-fullscreen')) + self.window.attributes('-fullscreen', not is_fullscreen) class AxisMenu: @@ -919,4 +918,4 @@ def hidetip(self): tw = self.tipwindow self.tipwindow = None if tw: - tw.destroy() \ No newline at end of file + tw.destroy() From 3bbbd0a27a56f33dbc619e4c6806b0844b7d5e55 Mon Sep 17 00:00:00 2001 From: Phil Elson Date: Mon, 21 May 2012 14:24:17 +0100 Subject: [PATCH 05/12] added modifier key support to the tk backend (i.e. ctrl+key). Additional support will need to be added for qt, gtk and wx backends. --- lib/matplotlib/backend_bases.py | 6 +++--- lib/matplotlib/backends/backend_tkagg.py | 15 +++++++++++++-- lib/matplotlib/rcsetup.py | 6 +++--- matplotlibrc.template | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index eb9b0e14c2b3..060a9555e89e 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1400,7 +1400,7 @@ class KeyEvent(LocationEvent): attributes, the following attributes are defined: *key* - the key pressed: None, chr(range(255), shift, win, or control + the key pressed: None, chr(range(255)), shift, win, or control This interface may change slightly when better support for modifier keys is included. @@ -2296,10 +2296,10 @@ def key_press_handler(event, canvas, toolbar=None): if event.key in fullscreen_keys: canvas.manager.full_screen_toggle() - # quit the figure (defaut key 'q') + # quit the figure (defaut key 'ctrl+w') if event.key in quit_keys: Gcf.destroy_fig(canvas.figure) - + if toolbar is not None: # home or reset mnemonic (default key 'h', 'home' and 'r') if event.key in home_keys: diff --git a/lib/matplotlib/backends/backend_tkagg.py b/lib/matplotlib/backends/backend_tkagg.py index 64aeae19123f..027caafe82ba 100644 --- a/lib/matplotlib/backends/backend_tkagg.py +++ b/lib/matplotlib/backends/backend_tkagg.py @@ -399,13 +399,24 @@ def _get_key(self, event): val = event.keysym_num if val in self.keyvald: key = self.keyvald[val] - elif val

Back | FazBrowse Home | New Git URL