コード例 #1
0
ファイル: backend_qt4.py プロジェクト: qsnake/matplotlib
 def _widgetclosed( self ):
     if self.window._destroying: return
     self.window._destroying = True
     try:
         Gcf.destroy(self.num)
     except AttributeError:
         pass
コード例 #2
0
ファイル: figuremanager.py プロジェクト: DanNixon/mantid
 def _widgetclosed(self):
     if self.window._destroying:
         return
     self.window._destroying = True
     map(self.canvas.mpl_disconnect, self._cids)
     try:
         Gcf.destroy(self.num)
     except AttributeError:
         pass
コード例 #3
0
    def __init__(self, canvas, num):
        self.window = Gtk.Window()
        super().__init__(canvas, num)

        self.window.set_wmclass("matplotlib", "Matplotlib")
        try:
            self.window.set_icon_from_file(window_icon)
        except Exception:
            # Some versions of gtk throw a glib.GError but not all, so I am not
            # sure how to catch it.  I am unhappy doing a blanket catch here,
            # but am not sure what a better way is - JDH
            _log.info('Could not load matplotlib icon: %s', sys.exc_info()[1])

        self.vbox = Gtk.Box()
        self.vbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self.window.add(self.vbox)
        self.vbox.show()

        self.canvas.show()

        self.vbox.pack_start(self.canvas, True, True, 0)
        # calculate size for window
        w = int(self.canvas.figure.bbox.width)
        h = int(self.canvas.figure.bbox.height)

        self.toolbar = self._get_toolbar()

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)

        if self.toolbar is not None:
            self.toolbar.show()
            self.vbox.pack_end(self.toolbar, False, False, 0)
            min_size, nat_size = self.toolbar.get_preferred_size()
            h += nat_size.height

        self.window.set_default_size(w, h)

        self._destroying = False
        self.window.connect("destroy", lambda *args: Gcf.destroy(self))
        self.window.connect("delete_event", lambda *args: Gcf.destroy(self))
        if mpl.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        self.canvas.grab_focus()
コード例 #4
0
    def __init__(self, canvas, num):
        app = _create_application()
        self.window = Gtk.Window()
        app.add_window(self.window)
        super().__init__(canvas, num)

        self.window.set_wmclass("matplotlib", "Matplotlib")
        icon_ext = "png" if sys.platform == "win32" else "svg"
        self.window.set_icon_from_file(
            str(cbook._get_data_path(f"images/matplotlib.{icon_ext}")))

        self.vbox = Gtk.Box()
        self.vbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self.window.add(self.vbox)
        self.vbox.show()

        self.canvas.show()

        self.vbox.pack_start(self.canvas, True, True, 0)
        # calculate size for window
        w = int(self.canvas.figure.bbox.width)
        h = int(self.canvas.figure.bbox.height)

        self.toolbar = self._get_toolbar()

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)

        if self.toolbar is not None:
            self.toolbar.show()
            self.vbox.pack_end(self.toolbar, False, False, 0)
            min_size, nat_size = self.toolbar.get_preferred_size()
            h += nat_size.height

        self.window.set_default_size(w, h)

        self._destroying = False
        self.window.connect("destroy", lambda *args: Gcf.destroy(self))
        self.window.connect("delete_event", lambda *args: Gcf.destroy(self))
        if mpl.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        self.canvas.grab_focus()
コード例 #5
0
ファイル: backend_nbagg.py プロジェクト: endolith/matplotlib
 def new_figure_manager_given_figure(num, figure):
     canvas = FigureCanvasNbAgg(figure)
     manager = FigureManagerNbAgg(canvas, num)
     if is_interactive():
         manager.show()
         figure.canvas.draw_idle()
     canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num))
     return manager
コード例 #6
0
 def new_figure_manager_given_figure(num, figure):
     canvas = FigureCanvasNbAgg(figure)
     manager = FigureManagerNbAgg(canvas, num)
     if is_interactive():
         manager.show()
         figure.canvas.draw_idle()
     canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num))
     return manager
コード例 #7
0
 def new_figure_manager_given_figure(num, figure):
     canvas = FigureCanvasNbAgg(figure)
     if rcParams['nbagg.transparent']:
         figure.patch.set_alpha(0)
     manager = FigureManagerNbAgg(canvas, num)
     if is_interactive():
         manager.show()
         figure.canvas.draw_idle()
     canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num))
     return manager
コード例 #8
0
ファイル: backend_nbagg.py プロジェクト: JIE2016G/matplotlib
 def new_figure_manager_given_figure(num, figure):
     canvas = FigureCanvasNbAgg(figure)
     if rcParams['nbagg.transparent']:
         figure.patch.set_alpha(0)
     manager = FigureManagerNbAgg(canvas, num)
     if is_interactive():
         manager.show()
         figure.canvas.draw_idle()
     canvas.mpl_connect('close_event', lambda event: Gcf.destroy(num))
     return manager
コード例 #9
0
    def destroy(self, *args):
        # check for qApp first, as PySide deletes it in its atexit handler
        if QApplication.instance() is None:
            return

        if self.window._destroying:
            return
        self.window._destroying = True

        if self.toolbar:
            self.toolbar.destroy()
        self._ads_observer.observeAll(False)
        del self._ads_observer
        self._fig_interaction.disconnect()
        self.window.close()

        try:
            Gcf.destroy(self.num)
        except AttributeError:
            pass
コード例 #10
0
ファイル: figuremanager.py プロジェクト: mantidproject/mantid
    def destroy(self, *args):
        # check for qApp first, as PySide deletes it in its atexit handler
        if QApplication.instance() is None:
            return

        if self.window._destroying:
            return
        self.window._destroying = True

        if self.toolbar:
            self.toolbar.destroy()
        self._ads_observer.observeAll(False)
        del self._ads_observer
        self._fig_interation.disconnect()
        self.window.close()

        try:
            Gcf.destroy(self.num)
        except AttributeError:
            pass
コード例 #11
0
ファイル: backend_gtk4.py プロジェクト: timhoffm/matplotlib
    def __init__(self, canvas, num):
        app = _create_application()
        self.window = Gtk.Window()
        app.add_window(self.window)
        super().__init__(canvas, num)

        self.vbox = Gtk.Box()
        self.vbox.set_property("orientation", Gtk.Orientation.VERTICAL)
        self.window.set_child(self.vbox)

        self.vbox.prepend(self.canvas)
        # calculate size for window
        w = int(self.canvas.figure.bbox.width)
        h = int(self.canvas.figure.bbox.height)

        self.toolbar = self._get_toolbar()

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)

        if self.toolbar is not None:
            sw = Gtk.ScrolledWindow(vscrollbar_policy=Gtk.PolicyType.NEVER)
            sw.set_child(self.toolbar)
            self.vbox.append(sw)
            min_size, nat_size = self.toolbar.get_preferred_size()
            h += nat_size.height

        self.window.set_default_size(w, h)

        self._destroying = False
        self.window.connect("destroy", lambda *args: Gcf.destroy(self))
        self.window.connect("close-request", lambda *args: Gcf.destroy(self))
        if mpl.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        self.canvas.grab_focus()
コード例 #12
0
def _close_figure(figure):
    """
    Workaround for matplotlib regression relating to closing figures in Agg

    See https://github.com/matplotlib/matplotlib/pull/18184/
    """
    # TODO It would be better to switch the approach based on matplotlib
    # versions known to have this problem, rather than blindly trying. Update
    # this once a fixed has been released and we know the earliest version of
    # matplotlib that does not have this bug.
    try:
        figure.canvas.close()
    except AttributeError:
        from matplotlib._pylab_helpers import Gcf

        num = next(
            (manager.num for manager in Gcf.figs.values()
             if manager.canvas.figure == figure),
            None,
        )
        if num is not None:
            Gcf.destroy(num)
コード例 #13
0
 def custom_show_func(*args, **kwargs):
     managers = Gcf.get_all_fig_managers()
     for m in managers:
         self.__all_figures.append(m.canvas.figure)
         self.__new_figures.append(m.canvas.figure)
         Gcf.destroy(m.num)
コード例 #14
0
 def close(self):
     Gcf.destroy(self.figman._num)
コード例 #15
0
 def destroy(*args): Gcf.destroy(num)
 self.window.connect("destroy", destroy)
コード例 #16
0
 def close(self):
     Gcf.destroy(self.figman._num)
コード例 #17
0
 def destroy(*args):
     Gcf.destroy(self)
コード例 #18
0
 def _widgetclosed( self ):
     if self.window._destroying: return
     self.window._destroying = True
     Gcf.destroy(self.num)
コード例 #19
0
 def show(self, **kwargs):
     self.canvas.show()
     Gcf.destroy(self._num)
コード例 #20
0
ファイル: backend_fltkagg.py プロジェクト: jcmdev0/matplotlib
 def destroy(self):
     self.window.hide()
     Fltk.Fl.wait(0)         # This is needed to make the last figure vanish.
     Gcf.destroy(self._num)
コード例 #21
0
 def destroy_figure(self, *args):
     # This is the callback from the gui destroy For this specific figure
     Gcf.destroy(self.num)
コード例 #22
0
def show():
    for manager in Gcf.get_all_fig_managers():
        manager.show()
        Gcf.destroy(manager.num)
コード例 #23
0
ファイル: backend_fltkagg.py プロジェクト: jcmdev0/matplotlib
def destroy_figure(ptr, figman):
    figman.window.hide()
    Fltk.Fl.wait(0)         # This is needed to make the last figure vanish.
    Gcf.destroy(figman._num)
コード例 #24
0
def show(block=None):
    for manager in Gcf.get_all_fig_managers():
        manager.show()

        # Do not re-display what is already shown.
        Gcf.destroy(manager.num)
コード例 #25
0
 def destroy(self):
     self.window.hide()
     Fltk.Fl.wait(0)  # This is needed to make the last figure vanish.
     Gcf.destroy(self._num)
コード例 #26
0
def destroy_figure(ptr, figman):
    figman.window.hide()
    Fltk.Fl.wait(0)  # This is needed to make the last figure vanish.
    Gcf.destroy(figman._num)
コード例 #27
0
ファイル: mpl_backend_xee.py プロジェクト: lpekelis/potoo
def show():
    for manager in Gcf.get_all_fig_managers():
        manager.show()
        Gcf.destroy(
            manager.num
        )  # Else every call to figure() will add an extra image produced by every future show()
コード例 #28
0
ファイル: backend_gtk.py プロジェクト: AndreI11/SatStressGui
 def destroy(*args):
     Gcf.destroy(num)
コード例 #29
0
 def close_foo(self):
     try:
         Gcf.destroy(self)
     except AttributeError:
         pass
コード例 #30
0
 def destroy(*args):
     self.window = None
     Gcf.destroy(self._num)
コード例 #31
0
 def _widgetclosed(self):
     if self.window._destroying: return
     self.window._destroying = True
     Gcf.destroy(self.num)
コード例 #32
0
 def Destroy(self, *args, **kwargs):
     self.isdestory = True
     self.canvas.close_event()
     self.canvas.stop_event_loop()
     Gcf.destroy(self.num)
     return super(MatplotPanel, self).Destroy(*args, **kwargs)
コード例 #33
0
def destroy_figure(ptr, figman):
    figman.window.hide()
    Gcf.destroy(figman._num)
コード例 #34
0
 def _onClose(self, evt):
     self.canvas.close_event()
     self.canvas.stop_event_loop()
     Gcf.destroy(self.num)
コード例 #35
0
 def closer(event):
     Gcf.destroy(num)
コード例 #36
0
 def _trigger_manager_draw(manager):
     if manager.canvas.figure.get_axes():
         manager.show()
         Gcf.destroy(manager)
コード例 #37
0
def destroy_figure(ptr, figman):
    figman.window.hide()
    Gcf.destroy(figman._num)
コード例 #38
0
 def closer(event):
     Gcf.destroy(0)
コード例 #39
0
ファイル: backend_tkagg.py プロジェクト: astraw/matplotlib
 def destroy(*args):
     self.window = None
     Gcf.destroy(self._num)
コード例 #40
0
 def show(self, **kwargs):
     self.canvas.show()
     Gcf.destroy(self._num)
コード例 #41
0
ファイル: backend_gtk3.py プロジェクト: jklymak/matplotlib
 def destroy(*args):
     Gcf.destroy(num)
コード例 #42
0
def show():
    for manager in Gcf.get_all_fig_managers():
        manager.show()
        # TODO(oleg): Check if it's okay to destroy manager here.
        Gcf.destroy(manager.num)
コード例 #43
0
 def close(self):
     Gcf.destroy(self.num)
コード例 #44
0
 def destroy(*args): Gcf.destroy(num)
 self.window.connect("destroy", destroy)
コード例 #45
0
 def destroy(event):
     canvas.mpl_disconnect(cid)
     Gcf.destroy(manager)
コード例 #46
0
 def close(self):
     Gcf.destroy(self)
     self.canvas.flush_events()