From ad83a789c0236563bdb6a2301500b57111dee4f9 Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Sun, 15 Jul 2012 11:45:08 -1000 Subject: [PATCH] qt4: remove duplicate file save button; and remove trailing whitespace --- lib/matplotlib/backend_bases.py | 36 ++++++++++++------------ lib/matplotlib/backends/backend_qt4.py | 39 +++++++++++--------------- 2 files changed, 35 insertions(+), 40 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index aa13b4bc98f9..90f747522a39 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -792,7 +792,7 @@ def get_gid(self): Return the object identifier if one is set, None otherwise. """ return self._gid - + def get_snap(self): """ returns the snap setting which may be: @@ -935,7 +935,7 @@ def set_gid(self, id): Sets the id. """ self._gid = id - + def set_snap(self, snap): """ Sets the snap setting which may be: @@ -1305,11 +1305,11 @@ class MouseEvent(LocationEvent): attributes, the following attributes are defined: *button* - button pressed None, 1, 2, 3, 'up', 'down' (up and down are used + button pressed None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events) *key* - the key depressed when the mouse event triggered (see + the key depressed when the mouse event triggered (see :class:`KeyEvent`) *step* @@ -1347,7 +1347,7 @@ def __init__(self, name, canvas, x, y, button=None, key=None, def __str__(self): return ("MPL MouseEvent: xy=(%d,%d) xydata=(%s,%s) button=%d " + - "dblclick=%s inaxes=%s") % (self.x, self.y, self.xdata, + "dblclick=%s inaxes=%s") % (self.x, self.y, self.xdata, self.ydata, self.button, self.dblclick, self.inaxes) @@ -1403,18 +1403,18 @@ class KeyEvent(LocationEvent): *key* the key(s) pressed. Could be **None**, a single case sensitive ascii - character ("g", "G", "#", etc.), a special key - ("control", "shift", "f1", "up", etc.) or a + character ("g", "G", "#", etc.), a special key + ("control", "shift", "f1", "up", etc.) or a combination of the above (e.g. "ctrl+alt+g", "ctrl+alt+G"). - + .. note:: - + Modifier keys will be prefixed to the pressed key and will be in the order "ctrl", "alt", "super". The exception to this rule is when the - pressed key is itself a modifier key, therefore "ctrl+alt" and + pressed key is itself a modifier key, therefore "ctrl+alt" and "alt+control" can both be valid key values. - - + + Example usage:: def on_key(event): @@ -1664,7 +1664,7 @@ def button_press_event(self, x, y, button, dblclick=False, guiEvent=None): """ self._button = button s = 'button_press_event' - mouseevent = MouseEvent(s, self, x, y, button, self._key, + mouseevent = MouseEvent(s, self, x, y, button, self._key, dblclick=dblclick, guiEvent=guiEvent) self.callbacks.process(s, mouseevent) @@ -2043,7 +2043,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w', bbox_extra_artists = self.figure.get_default_bbox_extra_artists() bb = [a.get_window_extent(renderer) for a in bbox_extra_artists] - + if bb: _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0]) @@ -2319,7 +2319,7 @@ def key_press_handler(event, canvas, toolbar=None): # 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: @@ -2494,12 +2494,12 @@ 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) + # image_file, # name of the image for the button (without the extension) # name_of_method, # name of the method in NavigationToolbar2 to call # ) toolitems = ( @@ -2608,7 +2608,7 @@ def mouse_move(self, event): if event.inaxes and event.inaxes.get_navigate(): - try: + try: s = event.inaxes.format_coord(event.xdata, event.ydata) except (ValueError, OverflowError): pass diff --git a/lib/matplotlib/backends/backend_qt4.py b/lib/matplotlib/backends/backend_qt4.py index 4adc609a8cc0..e36a8a110278 100644 --- a/lib/matplotlib/backends/backend_qt4.py +++ b/lib/matplotlib/backends/backend_qt4.py @@ -153,25 +153,25 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ): _modifier_keys = [ (QtCore.Qt.MetaModifier, 'super', QtCore.Qt.Key_Meta), (QtCore.Qt.AltModifier, 'alt', QtCore.Qt.Key_Alt), - (QtCore.Qt.ControlModifier, 'ctrl', QtCore.Qt.Key_Control) + (QtCore.Qt.ControlModifier, 'ctrl', QtCore.Qt.Key_Control) ] - + _ctrl_modifier = QtCore.Qt.ControlModifier - + if sys.platform == 'darwin': - # in OSX, the control and super (aka cmd/apple) keys are switched, so + # in OSX, the control and super (aka cmd/apple) keys are switched, so # switch them back. keyvald.update({ QtCore.Qt.Key_Control : 'super', # cmd/apple key QtCore.Qt.Key_Meta : 'control', }) - + _modifier_keys = [ (QtCore.Qt.ControlModifier, 'super', QtCore.Qt.Key_Control), (QtCore.Qt.AltModifier, 'alt', QtCore.Qt.Key_Alt), (QtCore.Qt.MetaModifier, 'ctrl', QtCore.Qt.Key_Meta), ] - + _ctrl_modifier = QtCore.Qt.MetaModifier # map Qt button codes to MouseEvent's ones: @@ -242,7 +242,7 @@ def mouseMoveEvent( self, event ): # flipy so y=0 is bottom of canvas y = self.figure.bbox.height - event.y() FigureCanvasBase.motion_notify_event( self, x, y ) - #if DEBUG: print 'mouse move' + #if DEBUG: print('mouse move') def mouseReleaseEvent( self, event ): x = event.x() @@ -304,16 +304,16 @@ def _get_key( self, event ): if event.key() < 256: key = unicode(event.text()) # if the control key is being pressed, we don't get the correct - # characters, so interpret them directly from the event.key(). - # Unfortunately, this means that we cannot handle key's case + # characters, so interpret them directly from the event.key(). + # Unfortunately, this means that we cannot handle key's case # since event.key() is not case sensitive, whereas event.text() is, # Finally, since it is not possible to get the CapsLock state - # we cannot accurately compute the case of a pressed key when + # we cannot accurately compute the case of a pressed key when # ctrl+shift+p is pressed. if int(event.modifiers()) & self._ctrl_modifier: # we always get an uppercase character key = chr(event.key()) - # if shift is not being pressed, lowercase it (as mentioned, + # if shift is not being pressed, lowercase it (as mentioned, # this does not take into account the CapsLock state) if not int(event.modifiers()) & QtCore.Qt.ShiftModifier: key = key.lower() @@ -322,9 +322,9 @@ def _get_key( self, event ): key = self.keyvald.get(event.key()) if key is not None: - # prepend the ctrl, alt, super keys if appropriate (sorted in that order) + # prepend the ctrl, alt, super keys if appropriate (sorted in that order) for modifier, prefix, Qt_key in self._modifier_keys: - if event.key() != Qt_key and int(event.modifiers()) & modifier == modifier: + if event.key() != Qt_key and int(event.modifiers()) & modifier == modifier: key = u'{}+{}'.format(prefix, key) return key @@ -437,7 +437,7 @@ def _show_message(self,s): def full_screen_toggle(self): if self.window.isFullScreen(): - self.window.showNormal() + self.window.showNormal() else: self.window.showFullScreen() @@ -505,20 +505,16 @@ def _init_toolbar(self): if text is None: self.addSeparator() else: - a = self.addAction(self._icon(image_file + '.png'), text, getattr(self, callback)) + 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) a.setToolTip('Edit curves line and axes parameters') - a = self.addAction(self._icon('filesave.png'), 'Save', - self.save_figure) - a.setToolTip('Save the figure') - - self.buttons = {} # Add the x,y location widget at the right side of the toolbar @@ -628,7 +624,6 @@ def save_figure(self, *args): selectedFilter = filter filters.append(filter) filters = ';;'.join(filters) - fname = _getSaveFileName(self, "Choose a filename to save to", start, filters, selectedFilter) if fname: