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

Skip to content

Commit e3b5cf2

Browse files
committed
refactored class toolbar in tkagg to support embedding
svn path=/trunk/matplotlib/; revision=804
1 parent 18dca66 commit e3b5cf2

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

.matplotlibrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
backend : GTKAgg # the default backend
3131
numerix : Numeric # Numeric or numarray
3232
interactive : False # see http://matplotlib.sourceforge.net/interactive.html
33-
toolbar : toolbar2 # None | classic | toolbar2
33+
toolbar : classic # None | classic | toolbar2
3434
timezone : UTC # a pytz timezone string, eg US/Central or Europe/Paris
3535

3636
# Where your matplotlib data lives if you installed to a non-default

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
New entries should be added at the top
22

3+
2004-12-22 Refactored NavigationToolbar in tkagg to support app
4+
embedding , init now takes (canvas, window) rather than
5+
(canvas, figman) - JDH
6+
37
2004-12-21 Refactored axes and subplot management - removed
48
add_subplot and add_axes from the FigureManager. classic
59
toolbar updates are done via an observer pattern on the

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def __init__(self, canvas, num, window):
261261
w, h = int(w), int(h)
262262
self.window.minsize(int(w*3/4),int(h*3/4))
263263
if matplotlib.rcParams['toolbar']=='classic':
264-
self.toolbar = NavigationToolbar( canvas, self )
264+
self.toolbar = NavigationToolbar( canvas, self.window )
265265
elif matplotlib.rcParams['toolbar']=='toolbar2':
266266
self.toolbar = NavigationToolbar2TkAgg( canvas, self.window )
267267
else:
@@ -380,14 +380,15 @@ def _Button(self, text, file, command):
380380
b.pack(side=Tk.LEFT)
381381
return b
382382

383-
def __init__(self, canvas, figman):
383+
def __init__(self, canvas, window):
384+
self.canvas = canvas
385+
self.window = window
386+
384387
xmin, xmax = canvas.figure.bbox.intervalx().get_bounds()
385388
height, width = 50, xmax-xmin
386-
Tk.Frame.__init__(self, master=figman.window,
389+
Tk.Frame.__init__(self, master=self.window,
387390
width=width, height=height,
388391
borderwidth=2)
389-
self.canvas = canvas
390-
self.figman = figman
391392

392393
self.update() # Make axes menu
393394

@@ -429,8 +430,6 @@ def __init__(self, canvas, figman):
429430

430431
self.pack(side=Tk.BOTTOM, fill=Tk.X)
431432

432-
def close(self):
433-
Gcf.destroy(self.figman._num)
434433

435434
def set_active(self, ind):
436435
self._ind = ind
@@ -444,7 +443,7 @@ def panx(self, arg):
444443
else: direction=-1
445444
for a in self._active:
446445
a.panx(direction)
447-
self.figman.show()
446+
self.canvas.draw()
448447

449448
def pany(self, arg):
450449
try: arg.direction
@@ -454,7 +453,7 @@ def pany(self, arg):
454453
else: direction=-1
455454
for a in self._active:
456455
a.pany(direction)
457-
self.figman.show()
456+
self.canvas.draw()
458457

459458
def zoomx(self, arg):
460459
try: arg.direction
@@ -465,7 +464,7 @@ def zoomx(self, arg):
465464

466465
for a in self._active:
467466
a.zoomx(direction)
468-
self.figman.show()
467+
self.canvas.draw()
469468

470469
def zoomy(self, arg):
471470
try: arg.direction
@@ -476,10 +475,10 @@ def zoomy(self, arg):
476475

477476
for a in self._active:
478477
a.zoomy(direction)
479-
self.figman.show()
478+
self.canvas.draw()
480479

481480
def save_figure(self):
482-
fs = FileDialog.SaveFileDialog(master=self.figman.window,
481+
fs = FileDialog.SaveFileDialog(master=self.window,
483482
title='Save the figure')
484483
try:
485484
self.lastDir

0 commit comments

Comments
 (0)