Skip to content

Commit 67257e7

Browse files
OceanWolffariza
authored andcommitted
Moved default_tool initilisation to FigureManagerBase and cleaned.
1 parent 94c711e commit 67257e7

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

lib/matplotlib/backend_bases.py

+10
Original file line numberDiff line numberDiff line change
@@ -2595,6 +2595,11 @@ def __init__(self, canvas, num):
25952595
25962596
"""
25972597

2598+
self.toolbar = self._get_toolbar()
2599+
self.navigation = self._get_navigation()
2600+
if rcParams['toolbar'] == 'navigation':
2601+
self.navigation.add_tools(tools.tools)
2602+
25982603
def show(self):
25992604
"""
26002605
For GUI backends, show the figure window and redraw.
@@ -2642,6 +2647,11 @@ def set_window_title(self, title):
26422647
"""
26432648
pass
26442649

2650+
def _get_toolbar(self):
2651+
return None
2652+
2653+
def _get_navigation(self):
2654+
return None
26452655

26462656
cursors = tools.cursors
26472657

lib/matplotlib/backends/backend_gtk3.py

-3
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,6 @@ def __init__(self, canvas, num):
416416

417417
self.vbox.pack_start(self.canvas, True, True, 0)
418418

419-
self.toolbar = self._get_toolbar()
420-
self.navigation = self._get_navigation()
421-
422419
# calculate size for window
423420
w = int (self.canvas.figure.bbox.width)
424421
h = int (self.canvas.figure.bbox.height)

lib/matplotlib/backends/backend_tkagg.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -525,11 +525,10 @@ class FigureManagerTkAgg(FigureManagerBase):
525525
window : The tk.Window
526526
"""
527527
def __init__(self, canvas, num, window):
528-
FigureManagerBase.__init__(self, canvas, num)
529528
self.window = window
529+
FigureManagerBase.__init__(self, canvas, num)
530530
self.window.withdraw()
531531
self.set_window_title("Figure %d" % num)
532-
self.canvas = canvas
533532
self._num = num
534533
if matplotlib.rcParams['toolbar']=='toolbar2':
535534
self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )

lib/matplotlib/pyplot.py

-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from matplotlib.cbook import _string_to_bool
3232
from matplotlib import docstring
3333
from matplotlib.backend_bases import FigureCanvasBase
34-
from matplotlib.backend_tools import tools as default_tools
3534
from matplotlib.figure import Figure, figaspect
3635
from matplotlib.gridspec import GridSpec
3736
from matplotlib.image import imread as _imread
@@ -434,9 +433,6 @@ def figure(num=None, # autoincrement if None, else integer from 1-N
434433
FigureClass=FigureClass,
435434
**kwargs)
436435

437-
if rcParams['toolbar'] == 'navigation':
438-
figManager.navigation.add_tools(default_tools)
439-
440436
if figLabel:
441437
figManager.set_window_title(figLabel)
442438
figManager.canvas.figure.set_label(figLabel)

0 commit comments

Comments
 (0)