From: Todd M. <jm...@st...> - 2004-12-20 20:02:16
|
Hi John, I looked over the diffs and they look fine; your analysis sounds plausible to me. I'll try to reproduce the problem using the test script and see if your fix removes it. If so, I'll go ahead and commit the changes. Todd On Mon, 2004-12-20 at 13:12 -0600, John Hunter wrote: > >>>>> "Axel" == Axel Kowald <A.K...@gm...> writes: > Axel> This is not really appropriate for me, since I read some > Axel> user input and decide then (after the script is running) if > Axel> I produce screen output or only a PS file :-( > > Axel> If you or anyone else finds a solution, please let me know. > > So this has nothing to do with the ps save. The core problem is > exposed by > > from pylab import * > plot([1,2,3]) > > with interactive false and no call to show. I traced the source of > the error message to binding the destroy event to the window. > Apparently the destroy is being called but the window is never shown. > By moving the destroy binding into the figure manager show method, all > appears to be fixed. Todd, you may want to look over this but I think > it's sound > > Axel, try replacing the FigureManagerTkAgg code in > site-packages/matplotlib/backends/backend_tkagg.py with the following > > class FigureManagerTkAgg(FigureManagerBase): > """ > Public attributes > > canvas : The FigureCanvas instance > num : The Figure number > toolbar : The tk.Toolbar > window : The tk.Window > """ > def __init__(self, canvas, num, window): > FigureManagerBase.__init__(self, canvas, num) > self.window = window > self.window.withdraw() > self.window.wm_title("Figure %d" % num) > self.canvas = canvas > self._num = num > t1,t2,w,h = canvas.figure.bbox.get_bounds() > w, h = int(w), int(h) > self.window.minsize(int(w*3/4),int(h*3/4)) > if matplotlib.rcParams['toolbar']=='classic': > self.toolbar = NavigationToolbar( canvas, self ) > elif matplotlib.rcParams['toolbar']=='toolbar2': > self.toolbar = NavigationToolbar2TkAgg( canvas, self.window ) > else: > self.toolbar = None > if self.toolbar is not None: > self.toolbar.update() > self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1) > self._shown = False > > def resize(self, event): > width, height = event.width, event.height > self.toolbar.configure(width=width) # , height=height) > > def show(self): > def destroy(*args): > self.window = None > Gcf.destroy(self._num) > if not self._shown: self.window.bind("<Destroy>", destroy) > > _focus = windowing.FocusManager() > self.window.deiconify() > self.canvas.draw() > self._shown = True > > def add_subplot(self, *args, **kwargs): > a = FigureManagerBase.add_subplot(self, *args, **kwargs) > if self.toolbar is not None: > self.toolbar.update() > return a > > def add_axes(self, rect, **kwargs): > a = FigureManagerBase.add_axes(self, rect, **kwargs) > if self.toolbar is not None: > self.toolbar.update() > return a > > def set_current_axes(self, a): > if a not in self.axes.values(): > error_msg_tkpaint('Axes is not in current figure') > FigureManagerBase.set_current_axes(self, a) > > def destroy(self, *args): > if Gcf.get_num_fig_managers()==0 and not matplotlib.is_interactive(): > if self.window is not None: > self.window.quit() > if self.window is not None: > self.window.destroy() > self.window = None > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://productguide.itmanagersjournal.com/ > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |