Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f7f05e

Browse files
committed
Finish MEP22 conversion
1 parent bc99129 commit 7f7f05e

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

lib/matplotlib/backend_bases.py

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

2764-
if rcParams['toolbar'] != 'toolmanager':
2765-
self.key_press_handler_id = self.canvas.mpl_connect(
2766-
'key_press_event',
2767-
self.key_press)
2768-
else:
2769-
self.key_press_handler_id = None
2764+
self.key_press_handler_id = self.canvas.mpl_connect('key_press_event',
2765+
self.key_press)
27702766
"""
27712767
The returned id from connecting the default key handler via
27722768
: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
@@ -353,7 +352,12 @@ class ToolQuit(ToolBase):
353352
default_keymap = rcParams['keymap.quit']
354353

355354
def trigger(self, sender, event, data=None):
356-
Gcf.destroy_fig(self.figure)
355+
try:
356+
manager = self.figure.canvas.manager
357+
except:
358+
pass
359+
else:
360+
manager._destroy('window_destroy_event')
357361

358362

359363
class ToolQuitAll(ToolBase):

lib/matplotlib/backends/backend_gtk3.py

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

435435
flow = _flow[not _flow.index(self._layout[place].get_orientation())]
436436
separator = Gtk.Separator(orientation=flow)
437+
separator.show()
437438
if place in ['north', 'west', 'center']:
438439
self._layout[place].pack_start(element, expand, fill, pad)
439440
self._layout[place].pack_start(separator, False, False, 0)
@@ -508,24 +509,14 @@ def __init__(self, canvas, num):
508509
w = int (self.canvas.figure.bbox.width)
509510
h = int (self.canvas.figure.bbox.height)
510511

511-
self.toolmanager = self._get_toolmanager()
512512
self.toolbar = self._get_toolbar()
513-
self.statusbar = None
514513

515514
def add_widget(child, expand, fill, padding):
516515
child.show()
517516
self.vbox.pack_end(child, False, False, 0)
518517
size_request = child.size_request()
519518
return size_request.height
520519

521-
if self.toolmanager:
522-
backend_tools.add_tools_to_manager(self.toolmanager)
523-
if self.toolbar:
524-
backend_tools.add_tools_to_container(self.toolbar)
525-
self.statusbar = StatusbarGTK3(self.toolmanager)
526-
h += add_widget(self.statusbar, False, False, 0)
527-
h += add_widget(Gtk.HSeparator(), False, False, 0)
528-
529520
if self.toolbar is not None:
530521
self.toolbar.show()
531522
h += add_widget(self.toolbar, False, False, 0)
@@ -542,9 +533,7 @@ def destroy(*args):
542533

543534
def notify_axes_change(fig):
544535
'this will be called whenever the current axes is changed'
545-
if self.toolmanager is not None:
546-
pass
547-
elif self.toolbar is not None:
536+
if self.toolbar is not None:
548537
self.toolbar.update()
549538
self.canvas.figure.add_axobserver(notify_axes_change)
550539

@@ -581,20 +570,10 @@ def _get_toolbar(self):
581570
# attrs are set
582571
if rcParams['toolbar'] == 'toolbar2':
583572
toolbar = NavigationToolbar2GTK3 (self.canvas, self.window)
584-
elif rcParams['toolbar'] == 'toolmanager':
585-
toolbar = ToolbarGTK3(self.toolmanager)
586573
else:
587574
toolbar = None
588575
return toolbar
589576

590-
def _get_toolmanager(self):
591-
# must be initialised after toolbar has been setted
592-
if rcParams['toolbar'] != 'toolbar2':
593-
toolmanager = ToolManager(self.canvas.figure)
594-
else:
595-
toolmanager = None
596-
return toolmanager
597-
598577
def get_window_title(self):
599578
return self.window.get_title()
600579

0 commit comments

Comments
 (0)