Skip to content
This repository

qt4: remove duplicate file save button; and remove trailing whitespace #1014

Merged
merged 1 commit into from almost 2 years ago

2 participants

Eric Firing Phil Elson
Eric Firing
Owner

No description provided.

Phil Elson
Collaborator
pelson commented

Thanks Eric. This is good to go.

The trailing whitespaces have been added by me. In general I am using a combination of PyDev for Eclipse (indigo) and vim (vanilla). How have you got your setup configured to avoid this whitespace junk?

Eric Firing
Owner

I use an editor that always removes trailing whitespace upon saving. I may be the only person using this editor: http://currents.soest.hawaii.edu/hgstage/zed/. I have not been able to find any trace of the original author for many years. In any case, most other people seem to use emacs, so our docs include instructions on how to configure it:
http://matplotlib.sourceforge.net/devel/coding_guide.html. For vim I find this: http://vim.wikia.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace
and for pydev, this:
http://vim.wikia.com/wiki/Remove_unwanted_spaces#Automatically_removing_all_trailing_whitespace.

If these things work for you, perhaps you would like to make a pull request to add these tips to the coding_guide?

Eric Firing efiring merged commit 43968f1 into from
Eric Firing efiring closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
36  lib/matplotlib/backend_bases.py
@@ -792,7 +792,7 @@ def get_gid(self):
792 792
         Return the object identifier if one is set, None otherwise.
793 793
         """
794 794
         return self._gid
795  
-        
  795
+
796 796
     def get_snap(self):
797 797
         """
798 798
         returns the snap setting which may be:
@@ -935,7 +935,7 @@ def set_gid(self, id):
935 935
         Sets the id.
936 936
         """
937 937
         self._gid = id
938  
-        
  938
+
939 939
     def set_snap(self, snap):
940 940
         """
941 941
         Sets the snap setting which may be:
@@ -1305,11 +1305,11 @@ class MouseEvent(LocationEvent):
1305 1305
     attributes, the following attributes are defined:
1306 1306
 
1307 1307
     *button*
1308  
-        button pressed None, 1, 2, 3, 'up', 'down' (up and down are used 
  1308
+        button pressed None, 1, 2, 3, 'up', 'down' (up and down are used
1309 1309
         for scroll events)
1310 1310
 
1311 1311
     *key*
1312  
-        the key depressed when the mouse event triggered (see 
  1312
+        the key depressed when the mouse event triggered (see
1313 1313
         :class:`KeyEvent`)
1314 1314
 
1315 1315
     *step*
@@ -1347,7 +1347,7 @@ def __init__(self, name, canvas, x, y, button=None, key=None,
1347 1347
 
1348 1348
     def __str__(self):
1349 1349
         return ("MPL MouseEvent: xy=(%d,%d) xydata=(%s,%s) button=%d " +
1350  
-                "dblclick=%s inaxes=%s") % (self.x, self.y, self.xdata, 
  1350
+                "dblclick=%s inaxes=%s") % (self.x, self.y, self.xdata,
1351 1351
                 self.ydata, self.button, self.dblclick, self.inaxes)
1352 1352
 
1353 1353
 
@@ -1403,18 +1403,18 @@ class KeyEvent(LocationEvent):
1403 1403
 
1404 1404
     *key*
1405 1405
         the key(s) pressed. Could be **None**, a single case sensitive ascii
1406  
-        character ("g", "G", "#", etc.), a special key 
1407  
-        ("control", "shift", "f1", "up", etc.) or a 
  1406
+        character ("g", "G", "#", etc.), a special key
  1407
+        ("control", "shift", "f1", "up", etc.) or a
1408 1408
         combination of the above (e.g. "ctrl+alt+g", "ctrl+alt+G").
1409  
-    
  1409
+
1410 1410
     .. note::
1411  
-     
  1411
+
1412 1412
         Modifier keys will be prefixed to the pressed key and will be in the
1413 1413
         order "ctrl", "alt", "super". The exception to this rule is when the
1414  
-        pressed key is itself a modifier key, therefore "ctrl+alt" and 
  1414
+        pressed key is itself a modifier key, therefore "ctrl+alt" and
1415 1415
         "alt+control" can both be valid key values.
1416  
-    
1417  
-         
  1416
+
  1417
+
1418 1418
     Example usage::
1419 1419
 
1420 1420
         def on_key(event):
@@ -1664,7 +1664,7 @@ def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
1664 1664
         """
1665 1665
         self._button = button
1666 1666
         s = 'button_press_event'
1667  
-        mouseevent = MouseEvent(s, self, x, y, button, self._key, 
  1667
+        mouseevent = MouseEvent(s, self, x, y, button, self._key,
1668 1668
                                 dblclick=dblclick, guiEvent=guiEvent)
1669 1669
         self.callbacks.process(s, mouseevent)
1670 1670
 
@@ -2043,7 +2043,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
2043 2043
                     bbox_extra_artists = self.figure.get_default_bbox_extra_artists()
2044 2044
 
2045 2045
                 bb = [a.get_window_extent(renderer) for a in bbox_extra_artists]
2046  
-                
  2046
+
2047 2047
                 if bb:
2048 2048
                     _bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0])
2049 2049
 
@@ -2319,7 +2319,7 @@ def key_press_handler(event, canvas, toolbar=None):
2319 2319
     # quit the figure (defaut key 'ctrl+w')
2320 2320
     if event.key in quit_keys:
2321 2321
         Gcf.destroy_fig(canvas.figure)
2322  
-       
  2322
+
2323 2323
     if toolbar is not None:
2324 2324
         # home or reset mnemonic  (default key 'h', 'home' and 'r')
2325 2325
         if event.key in home_keys:
@@ -2494,12 +2494,12 @@ class NavigationToolbar2(object):
2494 2494
 
2495 2495
     That's it, we'll do the rest!
2496 2496
     """
2497  
-    
  2497
+
2498 2498
     # list of toolitems to add to the toolbar, format is:
2499 2499
     # (
2500 2500
     #   text, # the text of the button (often not visible to users)
2501 2501
     #   tooltip_text, # the tooltip shown on hover (where possible)
2502  
-    #   image_file, # name of the image for the button (without the extension) 
  2502
+    #   image_file, # name of the image for the button (without the extension)
2503 2503
     #   name_of_method, # name of the method in NavigationToolbar2 to call
2504 2504
     # )
2505 2505
     toolitems = (
@@ -2608,7 +2608,7 @@ def mouse_move(self, event):
2608 2608
 
2609 2609
         if event.inaxes and event.inaxes.get_navigate():
2610 2610
 
2611  
-            try: 
  2611
+            try:
2612 2612
                 s = event.inaxes.format_coord(event.xdata, event.ydata)
2613 2613
             except (ValueError, OverflowError):
2614 2614
                 pass
39  lib/matplotlib/backends/backend_qt4.py
@@ -153,25 +153,25 @@ class FigureCanvasQT( QtGui.QWidget, FigureCanvasBase ):
153 153
     _modifier_keys = [
154 154
                       (QtCore.Qt.MetaModifier, 'super', QtCore.Qt.Key_Meta),
155 155
                       (QtCore.Qt.AltModifier, 'alt', QtCore.Qt.Key_Alt),
156  
-                      (QtCore.Qt.ControlModifier, 'ctrl', QtCore.Qt.Key_Control) 
  156
+                      (QtCore.Qt.ControlModifier, 'ctrl', QtCore.Qt.Key_Control)
157 157
                       ]
158  
-    
  158
+
159 159
     _ctrl_modifier = QtCore.Qt.ControlModifier
160  
-    
  160
+
161 161
     if sys.platform == 'darwin':
162  
-        # in OSX, the control and super (aka cmd/apple) keys are switched, so 
  162
+        # in OSX, the control and super (aka cmd/apple) keys are switched, so
163 163
         # switch them back.
164 164
         keyvald.update({
165 165
                         QtCore.Qt.Key_Control : 'super', # cmd/apple key
166 166
                         QtCore.Qt.Key_Meta : 'control',
167 167
                         })
168  
-        
  168
+
169 169
         _modifier_keys = [
170 170
                           (QtCore.Qt.ControlModifier, 'super', QtCore.Qt.Key_Control),
171 171
                           (QtCore.Qt.AltModifier, 'alt', QtCore.Qt.Key_Alt),
172 172
                           (QtCore.Qt.MetaModifier, 'ctrl', QtCore.Qt.Key_Meta),
173 173
                          ]
174  
-        
  174
+
175 175
         _ctrl_modifier = QtCore.Qt.MetaModifier
176 176
 
177 177
     # map Qt button codes to MouseEvent's ones:
@@ -242,7 +242,7 @@ def mouseMoveEvent( self, event ):
242 242
         # flipy so y=0 is bottom of canvas
243 243
         y = self.figure.bbox.height - event.y()
244 244
         FigureCanvasBase.motion_notify_event( self, x, y )
245  
-        #if DEBUG: print 'mouse move'
  245
+        #if DEBUG: print('mouse move')
246 246
 
247 247
     def mouseReleaseEvent( self, event ):
248 248
         x = event.x()
@@ -304,16 +304,16 @@ def _get_key( self, event ):
304 304
         if event.key() < 256:
305 305
             key = unicode(event.text())
306 306
             # if the control key is being pressed, we don't get the correct
307  
-            # characters, so interpret them directly from the event.key(). 
308  
-            # Unfortunately, this means that we cannot handle key's case 
  307
+            # characters, so interpret them directly from the event.key().
  308
+            # Unfortunately, this means that we cannot handle key's case
309 309
             # since event.key() is not case sensitive, whereas event.text() is,
310 310
             # Finally, since it is not possible to get the CapsLock state
311  
-            # we cannot accurately compute the case of a pressed key when 
  311
+            # we cannot accurately compute the case of a pressed key when
312 312
             # ctrl+shift+p is pressed.
313 313
             if int(event.modifiers()) & self._ctrl_modifier:
314 314
                 # we always get an uppercase character
315 315
                 key = chr(event.key())
316  
-                # if shift is not being pressed, lowercase it (as mentioned, 
  316
+                # if shift is not being pressed, lowercase it (as mentioned,
317 317
                 # this does not take into account the CapsLock state)
318 318
                 if not int(event.modifiers()) & QtCore.Qt.ShiftModifier:
319 319
                     key = key.lower()
@@ -322,9 +322,9 @@ def _get_key( self, event ):
322 322
             key = self.keyvald.get(event.key())
323 323
 
324 324
         if key is not None:
325  
-            # prepend the ctrl, alt, super keys if appropriate (sorted in that order) 
  325
+            # prepend the ctrl, alt, super keys if appropriate (sorted in that order)
326 326
             for modifier, prefix, Qt_key in self._modifier_keys:
327  
-                if event.key() != Qt_key and int(event.modifiers()) & modifier == modifier: 
  327
+                if event.key() != Qt_key and int(event.modifiers()) & modifier == modifier:
328 328
                     key = u'{}+{}'.format(prefix, key)
329 329
 
330 330
         return key
@@ -437,7 +437,7 @@ def _show_message(self,s):
437 437
 
438 438
     def full_screen_toggle(self):
439 439
         if self.window.isFullScreen():
440  
-            self.window.showNormal()    
  440
+            self.window.showNormal()
441 441
         else:
442 442
             self.window.showFullScreen()
443 443
 
@@ -505,20 +505,16 @@ def _init_toolbar(self):
505 505
             if text is None:
506 506
                 self.addSeparator()
507 507
             else:
508  
-                a = self.addAction(self._icon(image_file + '.png'), text, getattr(self, callback))
  508
+                a = self.addAction(self._icon(image_file + '.png'),
  509
+                                         text, getattr(self, callback))
509 510
                 if tooltip_text is not None:
510 511
                     a.setToolTip(tooltip_text)
511  
-                    
  512
+
512 513
         if figureoptions is not None:
513 514
             a = self.addAction(self._icon("qt4_editor_options.png"),
514 515
                                'Customize', self.edit_parameters)
515 516
             a.setToolTip('Edit curves line and axes parameters')
516 517
 
517  
-        a = self.addAction(self._icon('filesave.png'), 'Save',
518  
-                self.save_figure)
519  
-        a.setToolTip('Save the figure')
520  
-
521  
-
522 518
         self.buttons = {}
523 519
 
524 520
         # Add the x,y location widget at the right side of the toolbar
@@ -628,7 +624,6 @@ def save_figure(self, *args):
628 624
                 selectedFilter = filter
629 625
             filters.append(filter)
630 626
         filters = ';;'.join(filters)
631  
-
632 627
         fname = _getSaveFileName(self, "Choose a filename to save to",
633 628
                                         start, filters, selectedFilter)
634 629
         if fname:
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.