Пример #1
0
def new_figure_manager_given_figure(num, figure):
    """
    Create a new figure manager instance for the given figure.
    """
    _focus = windowing.FocusManager()
    window = Tk.Tk()
    window.withdraw()

    if Tk.TkVersion >= 8.5:
        # put a mpl icon on the window rather than the default tk icon. Tkinter
        # doesn't allow colour icons on linux systems, but tk >=8.5 has a iconphoto
        # command which we call directly. Source:
        # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
        icon_fname = os.path.join(rcParams['datapath'], 'images',
                                  'matplotlib.ppm')
        icon_img = Tk.PhotoImage(file=icon_fname)
        try:
            window.tk.call('wm', 'iconphoto', window._w, icon_img)
        except (SystemExit, KeyboardInterrupt):
            # re-raise exit type Exceptions
            raise
        except:
            # log the failure, but carry on
            verbose.report('Could not load matplotlib icon: %s' %
                           sys.exc_info()[1])

    canvas = FigureCanvasTkAgg(figure, master=window)
    figManager = FigureManagerTkAgg(canvas, num, window)
    if matplotlib.is_interactive():
        figManager.show()
        canvas.draw_idle()
    return figManager
Пример #2
0
    def new_figure_manager_given_figure(num, figure):
        """
        Create a new figure manager instance for the given figure.
        """
        _focus = windowing.FocusManager()
        window = Tk.Tk(className="matplotlib")
        window.withdraw()

        # Put a mpl icon on the window rather than the default tk icon.
        # Tkinter doesn't allow colour icons on linux systems, but tk>=8.5 has
        # a iconphoto command which we call directly. Source:
        # http://mail.python.org/pipermail/tkinter-discuss/2006-November/000954.html
        icon_fname = os.path.join(rcParams['datapath'], 'images',
                                  'matplotlib.ppm')
        icon_img = Tk.PhotoImage(file=icon_fname)
        try:
            window.tk.call('wm', 'foobar', window._w, icon_img)
        except Exception as exc:
            # log the failure (due e.g. to Tk version), but carry on
            verbose.report('Could not load matplotlib icon: %s' % exc)

        canvas = FigureCanvasTkAgg(figure, master=window)
        manager = FigureManagerTkAgg(canvas, num, window)
        if matplotlib.is_interactive():
            manager.show()
            canvas.draw_idle()
        return manager
Пример #3
0
 def update(self):
     _focus = windowing.FocusManager()
     self._axes = self.canvas.figure.axes
     naxes = len(self._axes)
     if not hasattr(self, "omenu"):
         self.set_active(range(naxes))
         self.omenu = AxisMenu(master=self, naxes=naxes)
     else:
         self.omenu.adjust(naxes)
Пример #4
0
 def update(self):
     _focus = windowing.FocusManager()
     self._axes = self.canvas.figure.axes
     naxes = len(self._axes)
     #if not hasattr(self, "omenu"):
     #    self.set_active(range(naxes))
     #    self.omenu = AxisMenu(master=self, naxes=naxes)
     #else:
     #    self.omenu.adjust(naxes)
     NavigationToolbar2.update(self)
Пример #5
0
def new_figure_manager(num, *args, **kwargs):
    """
    Create a new figure manager instance
    """
    _focus = windowing.FocusManager()
    FigureClass = kwargs.pop('FigureClass', Figure)
    figure = FigureClass(*args, **kwargs)
    window = Tk.Tk()
    canvas = FigureCanvasTkAgg(figure, master=window)
    figManager = FigureManagerTkAgg(canvas, num, window)
    if matplotlib.is_interactive():
        figManager.show()
    return figManager
Пример #6
0
 def show(self):
     """
     this function doesn't segfault but causes the
     PyEval_RestoreThread: NULL state bug on win32
     """
     _focus = windowing.FocusManager()
     if not self._shown:
         def destroy(*args):
             self.window = None
             Gcf.destroy(self._num)
         self.canvas._tkcanvas.bind("<Destroy>", destroy)
         self.window.deiconify()
         # anim.py requires this
         self.window.update()
     else:
         self.canvas.draw_idle()
     self._shown = True
Пример #7
0
 def show(self):
     """
     this function doesn't segfault but causes the
     PyEval_RestoreThread: NULL state bug on win32
     """
     _focus = windowing.FocusManager()
     if not self._shown:
         def destroy(*args):
             self.window = None
             Gcf.destroy(self._num)
         self.canvas._tkcanvas.bind("<Destroy>", destroy)
         self.window.deiconify()
     else:
         self.canvas.draw_idle()
     # Raise the new window.
     self.canvas.manager.window.attributes('-topmost', 1)
     self.canvas.manager.window.attributes('-topmost', 0)
     self._shown = True
Пример #8
0
 def update(self):
     _focus = windowing.FocusManager()
     self._axes = self.canvas.figure.axes
     NavigationToolbar2.update(self)
Пример #9
0
 def show(self):
     _focus = windowing.FocusManager()
     self.canvas.draw()
     self.window.redraw()