Skip to content

Commit 724b622

Browse files
OceanWolftacaswell
authored andcommitted
Finish MEP22 conversion
1 parent 6b35d85 commit 724b622

File tree

4 files changed

+12
-31
lines changed

4 files changed

+12
-31
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2801,12 +2801,8 @@ def __init__(self, canvas, num):
28012801
canvas.manager = self # store a pointer to parent
28022802
self.num = num
28032803

2804-
if rcParams['toolbar'] != 'toolmanager':
2805-
self.key_press_handler_id = self.canvas.mpl_connect(
2806-
'key_press_event',
2807-
self.key_press)
2808-
else:
2809-
self.key_press_handler_id = None
2804+
self.key_press_handler_id = self.canvas.mpl_connect('key_press_event',
2805+
self.key_press)
28102806
"""
28112807
The returned id from connecting the default key handler via
28122808
:meth:`FigureCanvasBase.mpl_connnect`.

lib/matplotlib/backend_managers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, figure, num):
8383
self.canvas = self._backend.FigureCanvas(figure, manager=self)
8484

8585
self.key_press_handler_id = self.canvas.mpl_connect('key_press_event',
86-
self.key_press)
86+
self.key_press) if rcParams['toolbar'] != 'toolmanager' else None
8787

8888
w = int(self.canvas.figure.bbox.width)
8989
h = int(self.canvas.figure.bbox.height)
@@ -183,7 +183,7 @@ def _get_toolbar(self):
183183
def _get_toolmanager(self):
184184
# must be initialised after toolbar has been setted
185185
if rcParams['toolbar'] != 'toolbar2':
186-
toolmanager = ToolManager(self.canvas)
186+
toolmanager = ToolManager(self.canvas.figure)
187187
else:
188188
toolmanager = None
189189
return toolmanager

lib/matplotlib/backend_tools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
from matplotlib import rcParams
16-
from matplotlib._pylab_helpers import Gcf
1716
import matplotlib.cbook as cbook
1817
from weakref import WeakKeyDictionary
1918
import six
@@ -384,7 +383,12 @@ class ToolQuit(ToolBase):
384383
default_keymap = rcParams['keymap.quit']
385384

386385
def trigger(self, sender, event, data=None):
387-
Gcf.destroy_fig(self.figure)
386+
try:
387+
manager = self.figure.canvas.manager
388+
except:
389+
pass
390+
else:
391+
manager._destroy('window_destroy_event')
388392

389393

390394
class ToolQuitAll(ToolBase):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ def add_element_to_window(self, element, expand, fill, pad, place):
421421

422422
flow = _flow[not _flow.index(self._layout[place].get_orientation())]
423423
separator = Gtk.Separator(orientation=flow)
424+
separator.show()
424425
if place in ['north', 'west', 'center']:
425426
self._layout[place].pack_start(element, expand, fill, pad)
426427
self._layout[place].pack_start(separator, False, False, 0)
@@ -501,24 +502,14 @@ def __init__(self, canvas, num):
501502
w = int (self.canvas.figure.bbox.width)
502503
h = int (self.canvas.figure.bbox.height)
503504

504-
self.toolmanager = self._get_toolmanager()
505505
self.toolbar = self._get_toolbar()
506-
self.statusbar = None
507506

508507
def add_widget(child, expand, fill, padding):
509508
child.show()
510509
self.vbox.pack_end(child, False, False, 0)
511510
size_request = child.size_request()
512511
return size_request.height
513512

514-
if self.toolmanager:
515-
backend_tools.add_tools_to_manager(self.toolmanager)
516-
if self.toolbar:
517-
backend_tools.add_tools_to_container(self.toolbar)
518-
self.statusbar = StatusbarGTK3(self.toolmanager)
519-
h += add_widget(self.statusbar, False, False, 0)
520-
h += add_widget(Gtk.HSeparator(), False, False, 0)
521-
522513
if self.toolbar is not None:
523514
self.toolbar.show()
524515
h += add_widget(self.toolbar, False, False, 0)
@@ -535,9 +526,7 @@ def destroy(*args):
535526

536527
def notify_axes_change(fig):
537528
'this will be called whenever the current axes is changed'
538-
if self.toolmanager is not None:
539-
pass
540-
elif self.toolbar is not None:
529+
if self.toolbar is not None:
541530
self.toolbar.update()
542531
self.canvas.figure.add_axobserver(notify_axes_change)
543532

@@ -579,14 +568,6 @@ def _get_toolbar(self):
579568
toolbar = None
580569
return toolbar
581570

582-
def _get_toolmanager(self):
583-
# must be initialised after toolbar has been setted
584-
if rcParams['toolbar'] == 'toolmanager':
585-
toolmanager = ToolManager(self.canvas.figure)
586-
else:
587-
toolmanager = None
588-
return toolmanager
589-
590571
def get_window_title(self):
591572
return self.window.get_title()
592573

0 commit comments

Comments
 (0)