Skip to content

Commit a99367f

Browse files
committed
pep8
1 parent 2c2e649 commit a99367f

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

lib/matplotlib/backends/backend_tkagg.py

+28-21
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,13 @@ def notify_axes_change(fig):
546546
'this will be called whenever the current axes is changed'
547547
if self.navigation is not None:
548548
self.navigation.update()
549-
elif self.toolbar is not None: self.toolbar.update()
549+
elif self.toolbar is not None:
550+
self.toolbar.update()
550551
self.canvas.figure.add_axobserver(notify_axes_change)
551552

552553
def _get_toolbar(self, canvas):
553-
if matplotlib.rcParams['toolbar']=='toolbar2':
554-
toolbar = NavigationToolbar2TkAgg( canvas, self.window )
554+
if matplotlib.rcParams['toolbar'] == 'toolbar2':
555+
toolbar = NavigationToolbar2TkAgg(canvas, self.window)
555556
elif matplotlib.rcParams['toolbar'] == 'navigation':
556557
self.navigation = NavigationTk(canvas, ToolbarTk)
557558
toolbar = self.navigation.toolbar
@@ -898,16 +899,21 @@ def draw_rubberband(self, event, caller, x0, y0, x1, y1):
898899
if not self.canvas.widgetlock.available(caller):
899900
return
900901
height = self.canvas.figure.bbox.height
901-
y0 = height-y0
902-
y1 = height-y1
903-
try: self.lastrect
904-
except AttributeError: pass
905-
else: self.canvas._tkcanvas.delete(self.lastrect)
902+
y0 = height - y0
903+
y1 = height - y1
904+
try:
905+
self.lastrect
906+
except AttributeError:
907+
pass
908+
else:
909+
self.canvas._tkcanvas.delete(self.lastrect)
906910
self.lastrect = self.canvas._tkcanvas.create_rectangle(x0, y0, x1, y1)
907911

908912
def remove_rubberband(self, event, caller):
909-
try: self.lastrect
910-
except AttributeError: pass
913+
try:
914+
self.lastrect
915+
except AttributeError:
916+
pass
911917
else:
912918
self.canvas._tkcanvas.delete(self.lastrect)
913919
del self.lastrect
@@ -917,7 +923,7 @@ class ToolbarTk(ToolbarBase, Tk.Frame):
917923
def __init__(self, manager):
918924
ToolbarBase.__init__(self, manager)
919925
xmin, xmax = self.manager.canvas.figure.bbox.intervalx
920-
height, width = 50, xmax-xmin
926+
height, width = 50, xmax - xmin
921927
Tk.Frame.__init__(self, master=self.manager.window,
922928
width=int(width), height=int(height),
923929
borderwidth=2)
@@ -931,15 +937,14 @@ def _add_toolitem(self, name, tooltip_text, image_file, position,
931937
if tooltip_text is not None:
932938
ToolTip.createToolTip(button, tooltip_text)
933939
self._toolitems[name] = button
934-
940+
935941
def _Button(self, text, file, toggle):
936-
extension='.ppm'
937942
if file is not None:
938-
img_file = os.path.join(rcParams['datapath'], 'images', file )
943+
img_file = os.path.join(rcParams['datapath'], 'images', file)
939944
im = Tk.PhotoImage(master=self, file=img_file)
940945
else:
941946
im = None
942-
947+
943948
if not toggle:
944949
b = Tk.Button(
945950
master=self, text=text, padx=2, pady=2, image=im,
@@ -951,7 +956,7 @@ def _Button(self, text, file, toggle):
951956
b._ntimage = im
952957
b.pack(side=Tk.LEFT)
953958
return b
954-
959+
955960
def _button_click(self, name):
956961
self.manager.navigation._toolbar_callback(name)
957962

@@ -979,6 +984,7 @@ def _remove_toolitem(self, name):
979984
def set_toolitem_visibility(self, name, visible):
980985
pass
981986

987+
982988
class SaveFigureTk(SaveFigureBase):
983989
def trigger(self, *args):
984990
from six.moves import tkinter_tkfiledialog, tkinter_messagebox
@@ -1023,7 +1029,8 @@ def trigger(self, *args):
10231029
rcParams['savefig.directory'] = initialdir
10241030
else:
10251031
# save dir for next time
1026-
rcParams['savefig.directory'] = os.path.dirname(six.text_type(fname))
1032+
rcParams['savefig.directory'] = os.path.dirname(
1033+
six.text_type(fname))
10271034
try:
10281035
# This method will handle the delegation to the correct type
10291036
self.figure.canvas.print_figure(fname)
@@ -1034,16 +1041,16 @@ def trigger(self, *args):
10341041
class ConfigureSubplotsTk(ConfigureSubplotsBase):
10351042
def __init__(self, *args, **kwargs):
10361043
ConfigureSubplotsBase.__init__(self, *args, **kwargs)
1037-
toolfig = Figure(figsize=(6,3))
1044+
toolfig = Figure(figsize=(6, 3))
10381045
self.window = Tk.Tk()
1039-
1046+
10401047
canvas = FigureCanvasTkAgg(toolfig, master=self.window)
10411048
toolfig.subplots_adjust(top=0.9)
1042-
tool = SubplotTool(self.figure, toolfig)
1049+
_tool = SubplotTool(self.figure, toolfig)
10431050
canvas.show()
10441051
canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
10451052
self.window.protocol("WM_DELETE_WINDOW", self.destroy)
1046-
1053+
10471054
def trigger(self, event):
10481055
self.window.lift()
10491056

0 commit comments

Comments
 (0)