• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python backend_bases.FigureManagerBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.backend_bases.FigureManagerBase的典型用法代码示例。如果您正苦于以下问题:Python FigureManagerBase类的具体用法?Python FigureManagerBase怎么用?Python FigureManagerBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FigureManagerBase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, canvas, num):
     if _debug: print 'FigureManagerGTK.%s' % fn_name()
     FigureManagerBase.__init__(self, canvas, num)
     self.window = gtk.Window()
     self.window.set_title("Figure %d" % num)
     if (window_icon):
         self.window.set_icon_from_file(window_icon)
     self.vbox = gtk.VBox()
     self.window.add(self.vbox)
     self.vbox.show()
     self.canvas.show()
     self.canvas.figure.show = lambda *args: self.window.show()
     self.vbox.pack_start(self.canvas, True, True)
     self.toolbar = self._get_toolbar(canvas)
     w = int (self.canvas.figure.bbox.width)
     h = int (self.canvas.figure.bbox.height)
     if self.toolbar is not None:
         self.toolbar.show()
         self.vbox.pack_end(self.toolbar, False, False)
         tb_w, tb_h = self.toolbar.size_request()
         h += tb_h
     self.window.set_default_size (w, h)
     def destroy(*args):
         Gcf.destroy(num)
     self.window.connect("destroy", destroy)
     self.window.connect("delete_event", destroy)
     if matplotlib.is_interactive():
         self.window.show()
     def notify_axes_change(fig):
         'this will be called whenever the current axes is changed'
         if self.toolbar is not None: self.toolbar.update()
     self.canvas.figure.add_axobserver(notify_axes_change)
     self.canvas.grab_focus()
开发者ID:,项目名称:,代码行数:33,代码来源:


示例2: __init__

    def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)
        self.canvas = canvas

        window = MatPlotWindow(mainWin.workSpace)
        window.setup(canvas, num)
        self.window = window


        QtCore.QObject.connect(window, QtCore.SIGNAL('destroyed()'),
                            self._widgetclosed)
        window._destroying = False

        toolbar = self._get_toolbar(canvas, window)
        window.toolbar = toolbar
        self.toolbar = toolbar
        if toolbar:
           window.mainLayout.addWidget(toolbar, 0)

        window.resize(640, 480)

        if matplotlib.is_interactive():
            window.setMinimumSize(200, 200)
            window.show()

        def notify_axes_change(fig):
           # This will be called whenever the current axes is changed
           if self.toolbar != None: self.toolbar.update()
           self.canvas.figure.add_axobserver(notify_axes_change)
开发者ID:BackupTheBerlios,项目名称:simuvis4-svn,代码行数:29,代码来源:backend_sv4agg.py


示例3: __init__

    def __init__(self, *args, **kwargs):
        # pull non-standard keyword arguments
        refresh = kwargs.pop('auto_refresh', False)

        # dynamically set the subplot positions based on the figure size
        # -- only if the user hasn't customised the subplot params
        figsize = kwargs.get('figsize', rcParams['figure.figsize'])
        subplotpars = get_subplot_params(figsize)
        use_subplotpars = 'subplotpars' not in kwargs and all([
            rcParams['figure.subplot.%s' % pos] ==
            MPL_RCPARAMS['figure.subplot.%s' % pos] for
            pos in ('left', 'bottom', 'right', 'top')])
        if use_subplotpars:
            kwargs['subplotpars'] = subplotpars

        # generated figure, with associated interactivity from pyplot
        super(Plot, self).__init__(*args, **kwargs)
        backend_mod, _, draw_if_interactive, _ = backends.pylab_setup()
        try:
            manager = backend_mod.new_figure_manager_given_figure(1, self)
        except AttributeError:
            canvas = backend_mod.FigureCanvas(self)
            manager = FigureManagerBase(canvas, 1)
        cid = manager.canvas.mpl_connect(
            'button_press_event',
            lambda ev: _pylab_helpers.Gcf.set_active(manager))
        manager._cidgcf = cid
        _pylab_helpers.Gcf.set_active(manager)
        draw_if_interactive()

        # finalise
        self.set_auto_refresh(refresh)
        self.colorbars = []
        self._coloraxes = []
开发者ID:stefco,项目名称:gwpy,代码行数:34,代码来源:core.py


示例4: __init__

    def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        # If using toolmanager it has to be present when initializing the toolbar
        self.toolmanager = self._get_toolmanager()
        # packing toolbar first, because if space is getting low, last packed widget is getting shrunk first (-> the canvas)
        self.toolbar = self._get_toolbar()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._num = num

        self.statusbar = None

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)
                self.statusbar = StatusbarTk(self.window, self.toolmanager)

        self._shown = False

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolmanager is not None:
                pass
            elif self.toolbar is not None:
                self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)
开发者ID:dpritsos,项目名称:TeCA,代码行数:30,代码来源:_backend_tk.py


示例5: initWithFigure_number_

    def initWithFigure_number_(self, fig, num):
        """__init__"""

        win = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
            NSMakeRect(100, 100, 640, 480),
            NSBorderlessWindowMask
            | NSTitledWindowMask
            | NSClosableWindowMask
            | NSMiniaturizableWindowMask
            | NSResizableWindowMask,
            NSBackingStoreBuffered,
            True,
        )
        self = super(FigureManagerCocoa, self).initWithWindow_(win)
        if self != None:
            cViewBounds = self.window().contentView().bounds()
            plotViewFrame = NSMakeRect(0, 0, cViewBounds.size.width, cViewBounds.size.height)
            plotView = FigureCanvasView.alloc().initWithFrame_figure_(plotViewFrame, fig)
            plotView.setAutoresizingMask_(NSViewWidthSizable | NSViewHeightSizable)

            FigureManagerBase.__init__(self, plotView, num)

            self.window().contentView().addSubview_(plotView)
            self.window().setTitle_("Figure %d" % num)

            self.show_window()
        return self
开发者ID:zoccolan,项目名称:eyetracker,代码行数:27,代码来源:cocoa_backend.py


示例6: __init__

 def __init__(self, canvas, num):
     FigureManagerBase.__init__(self, canvas, num)
     global index
     index += 1
     self.canvas = canvas
     self._num = num
     self._shown = False
开发者ID:yuchuangu85,项目名称:intellij-community,代码行数:7,代码来源:backend_interagg.py


示例7: __init__

    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.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.window )
        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 notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar != None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)



        # attach a show method to the figure for pylab ease of use
        self.canvas.figure.show = lambda *args: self.show()
开发者ID:astraw,项目名称:matplotlib,代码行数:30,代码来源:backend_tkagg.py


示例8: __init__

    def __init__(self, canvas, num, window):
        FigureManagerBase.__init__(self, canvas, num)
        self.window = window
        self.window.withdraw()
        self.set_window_title("Figure %d" % num)
        self.canvas = canvas
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self._num = num

        self.toolmanager = self._get_toolmanager()
        self.toolbar = self._get_toolbar()
        self.statusbar = None

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)
                self.statusbar = StatusbarTk(self.window, self.toolmanager)

        self._shown = False

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolmanager is not None:
                pass
            elif self.toolbar is not None:
                self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)
开发者ID:kshramt,项目名称:matplotlib,代码行数:28,代码来源:backend_tkagg.py


示例9: __init__

    def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)

        self.window = Gtk.Window()
        self.window.set_wmclass("matplotlib", "Matplotlib")
        self.set_window_title("Figure %d" % num)
        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.toolmanager = self._get_toolmanager()
        self.toolbar = self._get_toolbar()
        self.statusbar = None

        def add_widget(child, expand, fill, padding):
            child.show()
            self.vbox.pack_end(child, False, False, 0)
            size_request = child.size_request()
            return size_request.height

        if self.toolmanager:
            backend_tools.add_tools_to_manager(self.toolmanager)
            if self.toolbar:
                backend_tools.add_tools_to_container(self.toolbar)
                self.statusbar = StatusbarGTK3(self.toolmanager)
                h += add_widget(self.statusbar, False, False, 0)
                h += add_widget(Gtk.HSeparator(), False, False, 0)

        if self.toolbar is not None:
            self.toolbar.show()
            h += add_widget(self.toolbar, False, False, 0)

        self.window.set_default_size(w, h)

        def destroy(*args):
            Gcf.destroy(num)
        self.window.connect("destroy", destroy)
        self.window.connect("delete_event", destroy)
        if matplotlib.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        self.canvas.grab_focus()
开发者ID:jklymak,项目名称:matplotlib,代码行数:59,代码来源:backend_gtk3.py


示例10: __init__

    def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)

        try:
            WMEnable('Matplotlib')
        except:
            # MULTIPLE FIGURES ARE BUGGY!
            pass # If there are multiple figures we only need to enable once
开发者ID:CTPUG,项目名称:matplotlib-py3,代码行数:8,代码来源:backend_cocoaagg.py


示例11: __init__

    def __init__(self, canvas, num):
        if DEBUG:
            print("FigureManagerQT.%s" % fn_name())
        FigureManagerBase.__init__(self, canvas, num)
        self.canvas = canvas
        self.window = MainWindow()
        self.window.closing.connect(canvas.close_event)
        self.window.closing.connect(self._widgetclosed)

        self.window.setWindowTitle("Figure %d" % num)
        image = os.path.join(matplotlib.rcParams["datapath"], "images", "matplotlib.png")
        self.window.setWindowIcon(QtGui.QIcon(image))

        # Give the keyboard focus to the figure instead of the
        # manager; StrongFocus accepts both tab and click to focus and
        # will enable the canvas to process event w/o clicking.
        # ClickFocus only takes the focus is the window has been
        # clicked
        # on. http://qt-project.org/doc/qt-4.8/qt.html#FocusPolicy-enum or
        # http://doc.qt.digia.com/qt/qt.html#FocusPolicy-enum
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.canvas.setFocus()

        self.window._destroying = False

        self.toolbar = self._get_toolbar(self.canvas, self.window)
        if self.toolbar is not None:
            self.window.addToolBar(self.toolbar)
            self.toolbar.message.connect(self._show_message)
            tbs_height = self.toolbar.sizeHint().height()
        else:
            tbs_height = 0

        # add text label to status bar
        self.statusbar_label = QtWidgets.QLabel()
        self.window.statusBar().addWidget(self.statusbar_label)

        # resize the main window so it will display the canvas with the
        # requested size:
        cs = canvas.sizeHint()
        sbs = self.window.statusBar().sizeHint()
        self._status_and_tool_height = tbs_height + sbs.height()
        height = cs.height() + self._status_and_tool_height
        self.window.resize(cs.width(), height)

        self.window.setCentralWidget(self.canvas)

        if matplotlib.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        def notify_axes_change(fig):
            # This will be called whenever the current axes is changed
            if self.toolbar is not None:
                self.toolbar.update()

        self.canvas.figure.add_axobserver(notify_axes_change)
        self.window.raise_()
开发者ID:zaherabdulazeez,项目名称:matplotlib,代码行数:58,代码来源:backend_qt5.py


示例12: __init__

    def __init__(self, canvas, num):
        if _debug:
            print("FigureManagerGTK.%s" % fn_name())
        FigureManagerBase.__init__(self, canvas, num)

        self.window = gtk.Window()
        self.window.set_title("Figure %d" % num)
        if window_icon:
            try:
                self.window.set_icon_from_file(window_icon)
            except:
                # some versions of gtk throw a glib.GError but not
                # all, so I am not sure how to catch it.  I am unhappy
                # diong a blanket catch here, but an not sure what a
                # better way is - JDH
                verbose.report("Could not load matplotlib icon: %s" % sys.exc_info()[1])

        self.vbox = gtk.VBox()
        self.window.add(self.vbox)
        self.vbox.show()

        self.canvas.show()

        # attach a show method to the figure  for pylab ease of use
        self.canvas.figure.show = lambda *args: self.window.show()

        self.vbox.pack_start(self.canvas, True, True)

        self.toolbar = self._get_toolbar(canvas)

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

        if self.toolbar is not None:
            self.toolbar.show()
            self.vbox.pack_end(self.toolbar, False, False)

            tb_w, tb_h = self.toolbar.size_request()
            h += tb_h
        self.window.set_default_size(w, h)

        def destroy(*args):
            Gcf.destroy(num)

        self.window.connect("destroy", destroy)
        self.window.connect("delete_event", destroy)
        if matplotlib.is_interactive():
            self.window.show()

        def notify_axes_change(fig):
            "this will be called whenever the current axes is changed"
            if self.toolbar is not None:
                self.toolbar.update()

        self.canvas.figure.add_axobserver(notify_axes_change)

        self.canvas.grab_focus()
开发者ID:astraw,项目名称:matplotlib,代码行数:58,代码来源:backend_gtk.py


示例13: __init__

    def __init__(self, canvas, num):
        if _debug: print 'FigureManagerGTK3.%s' % fn_name()
        FigureManagerBase.__init__(self, canvas, num)

        self.window = Gtk.Window()
        self.set_window_title("Figure %d" % num)
        try:
            self.window.set_icon_from_file(window_icon)
        except (SystemExit, KeyboardInterrupt):
            # re-raise exit type Exceptions
            raise
        except:
            # 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
            verbose.report('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()

        # attach a show method to the figure  for pylab ease of use
        self.canvas.figure.show = lambda *args: self.window.show()

        self.vbox.pack_start(self.canvas, True, True, 0)

        self.toolbar = self._get_toolbar(canvas)

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

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

        self.window.set_default_size (w, h)

        def destroy(*args):
            Gcf.destroy(num)
        self.window.connect("destroy", destroy)
        self.window.connect("delete_event", destroy)
        if matplotlib.is_interactive():
            self.window.show()

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar is not None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)

        self.canvas.grab_focus()
开发者ID:KennethNielsen,项目名称:matplotlib,代码行数:57,代码来源:backend_gtk3.py


示例14: __init__

    def __init__( self, canvas, num ):
        if DEBUG: print 'FigureManagerQT.%s' % fn_name()
        FigureManagerBase.__init__( self, canvas, num )
        self.canvas = canvas
        self.window = qt.QMainWindow( None, None, qt.Qt.WDestructiveClose )

        centralWidget = qt.QWidget( self.window )
        self.canvas.reparent( centralWidget, qt.QPoint( 0, 0 ) )
        
        # Give the keyboard focus to the figure instead of the manager
        self.canvas.setFocusPolicy( qt.QWidget.ClickFocus )
        self.canvas.setFocus()
        self.window.setCaption( "Figure %d" % num )

        qt.QObject.connect( self.window, qt.SIGNAL( 'destroyed()' ),
                            self._widgetclosed )
        self.window._destroying = False

        if matplotlib.rcParams['toolbar'] == 'classic':
            print "Classic toolbar is not yet supported"
            #self.toolbar = NavigationToolbarQT( centralWidget, canvas )
            self.toolbar = None
        elif matplotlib.rcParams['toolbar'] == 'toolbar2':
            self.toolbar = NavigationToolbar2QT( centralWidget, canvas )
        else:
            self.toolbar = None

        # Use a vertical layout for the plot and the toolbar.  Set the
        # stretch to all be in the plot so the toolbar doesn't resize.
        layout = qt.QVBoxLayout( centralWidget )
        layout.addWidget( self.canvas, 1 )
        if self.toolbar:
           layout.addWidget( self.toolbar, 0 )

        self.window.setCentralWidget( centralWidget )

        # Reset the window height so the canvas will be the right
        # size.  This ALMOST works right.  The first issue is that the
        # height w/ a toolbar seems to be off by just a little bit (so
        # we add 4 pixels).  The second is that the total width/height
        # is slightly smaller that we actually want.  It seems like
        # the border of the window is being included in the size but
        # AFAIK there is no way to get that size.  
        w = self.canvas.width()
        h = self.canvas.height()
        if self.toolbar:
           h += self.toolbar.height() + 4
        self.window.resize( w, h )
        
        if matplotlib.is_interactive():
            self.window.show()

        def notify_axes_change( fig ):
           # This will be called whenever the current axes is changed
           if self.toolbar != None: self.toolbar.update()
           self.canvas.figure.add_axobserver( notify_axes_change )
开发者ID:pv,项目名称:matplotlib-cvs,代码行数:56,代码来源:backend_qt.py


示例15: __init__

    def __init__(self, canvas, num):
        if DEBUG:
            print("FigureManagerQT.%s" % fn_name())
        FigureManagerBase.__init__(self, canvas, num)
        self.canvas = canvas
        self.window = qt.QMainWindow(None, None, qt.Qt.WDestructiveClose)
        self.window.closeEvent = self._widgetCloseEvent

        centralWidget = qt.QWidget(self.window)
        self.canvas.reparent(centralWidget, qt.QPoint(0, 0))

        # Give the keyboard focus to the figure instead of the manager
        self.canvas.setFocusPolicy(qt.QWidget.ClickFocus)
        self.canvas.setFocus()
        self.window.setCaption("Figure %d" % num)

        self.window._destroying = False

        self.toolbar = self._get_toolbar(self.canvas, centralWidget)

        # Use a vertical layout for the plot and the toolbar.  Set the
        # stretch to all be in the plot so the toolbar doesn't resize.
        self.layout = qt.QVBoxLayout(centralWidget)
        self.layout.addWidget(self.canvas, 1)

        if self.toolbar:
            self.layout.addWidget(self.toolbar, 0)

        self.window.setCentralWidget(centralWidget)

        # Reset the window height so the canvas will be the right
        # size.  This ALMOST works right.  The first issue is that the
        # height w/ a toolbar seems to be off by just a little bit (so
        # we add 4 pixels).  The second is that the total width/height
        # is slightly smaller that we actually want.  It seems like
        # the border of the window is being included in the size but
        # AFAIK there is no way to get that size.
        w = self.canvas.width()
        h = self.canvas.height()
        if self.toolbar:
            h += self.toolbar.height() + 4
        self.window.resize(w, h)

        if matplotlib.is_interactive():
            self.window.show()

        # attach a show method to the figure for pylab ease of use
        self.canvas.figure.show = lambda *args: self.window.show()

        def notify_axes_change(fig):
            # This will be called whenever the current axes is changed
            if self.toolbar != None:
                self.toolbar.update()

        self.canvas.figure.add_axobserver(notify_axes_change)
开发者ID:huard,项目名称:matplotlib,代码行数:55,代码来源:backend_qt.py


示例16: __init__

    def __init__( self, canvas, num ):
        if DEBUG: print('FigureManagerQT.%s' % fn_name())
        FigureManagerBase.__init__( self, canvas, num )
        self.canvas = canvas
        self.window = QtGui.QMainWindow()
        self.window.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        self.window.setWindowTitle("Figure %d" % num)
        image = os.path.join( matplotlib.rcParams['datapath'],'images','matplotlib.png' )
        self.window.setWindowIcon(QtGui.QIcon( image ))

        # Give the keyboard focus to the figure instead of the
        # manager; StrongFocus accepts both tab and click to focus and
        # will enable the canvas to process event w/o clicking.
        # ClickFocus only takes the focus is the window has been
        # clicked
        # on. http://developer.qt.nokia.com/doc/qt-4.8/qt.html#FocusPolicy-enum
        self.canvas.setFocusPolicy( QtCore.Qt.StrongFocus )
        self.canvas.setFocus()

        QtCore.QObject.connect( self.window, QtCore.SIGNAL( 'destroyed()' ),
                            self._widgetclosed )
        self.window._destroying = False

        self.toolbar = self._get_toolbar(self.canvas, self.window)
        if self.toolbar is not None:
            self.window.addToolBar(self.toolbar)
            QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
                                   self._show_message)
            tbs_height = self.toolbar.sizeHint().height()
        else:
            tbs_height = 0

        # resize the main window so it will display the canvas with the
        # requested size:
        cs = canvas.sizeHint()
        sbs = self.window.statusBar().sizeHint()
        self._status_and_tool_height = tbs_height+sbs.height()
        height = cs.height() + self._status_and_tool_height
        self.window.resize(cs.width(), height)

        self.window.setCentralWidget(self.canvas)

        if matplotlib.is_interactive():
            self.window.show()

        # attach a show method to the figure for pylab ease of use
        self.canvas.figure.show = lambda *args: self.window.show()

        def notify_axes_change( fig ):
            # This will be called whenever the current axes is changed
            if self.toolbar is not None:
                self.toolbar.update()
        self.canvas.figure.add_axobserver( notify_axes_change )
开发者ID:KennethNielsen,项目名称:matplotlib,代码行数:54,代码来源:backend_qt4.py


示例17: __init__

    def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)

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

        self.vbox = gtk.VBox()
        self.window.add(self.vbox)
        self.vbox.show()

        self.canvas.show()

        self.vbox.pack_start(self.canvas, True, True)

        self.toolbar = self._get_toolbar(canvas)

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

        if self.toolbar is not None:
            self.toolbar.show()
            self.vbox.pack_end(self.toolbar, False, False)

            tb_w, tb_h = self.toolbar.size_request()
            h += tb_h
        self.window.set_default_size (w, h)

        def destroy(*args):
            Gcf.destroy(num)
        self.window.connect("destroy", destroy)
        self.window.connect("delete_event", destroy)
        if matplotlib.is_interactive():
            self.window.show()
            self.canvas.draw_idle()

        def notify_axes_change(fig):
            'this will be called whenever the current axes is changed'
            if self.toolbar is not None: self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)

        self.canvas.grab_focus()
开发者ID:adnanb59,项目名称:matplotlib,代码行数:53,代码来源:backend_gtk.py


示例18: __init__

    def __init__(self, num):
        """ overwrite the FigureManageAt.__init__ """
        #focused = QtGui.QApplication.focusWidget()
        self.window = MplTabWidget.get_singleton()
        self.canvas, self.widget = self.window.add_tab_canvas(num, self._widgetclosed)
        FigureManagerBase.__init__(self, self.canvas, num)

        # self.window.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        ##image = os.path.join( mpl.rcParams['datapath'],'images','matplotlib.png' )
        ##self.window.setWindowIcon(QtGui.QIcon( image ))

        # Give the keyboard focus to the figure instead of the
        # manager; StrongFocus accepts both tab and click to focus and
        # will enable the canvas to process event w/o clicking.
        # ClickFocus only takes the focus is the window has been
        # clicked
        # on. http://developer.qt.nokia.com/doc/qt-4.8/qt.html#FocusPolicy-enum
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
        # self.canvas.setFocus()

        # QtCore.QObject.connect( self.widget, QtCore.SIGNAL( 'destroyed()' ),
        # self._widgetclosed )
        self.window._destroying = False

        self.toolbar = self._get_toolbar(self.canvas, self.widget)
        if self.toolbar is not None:
            self.widget.addToolBar(self.toolbar)
            QtCore.QObject.connect(self.toolbar, QtCore.SIGNAL("message"),
                                   self._show_message)
            tbs_height = self.toolbar.sizeHint().height()
        else:
            tbs_height = 0

        # resize the main window so it will display the canvas with the
        # requested size:
        ##cs = canvas.sizeHint()
        ##sbs = self.window.statusBar().sizeHint()
        ##self._status_and_tool_height = tbs_height+sbs.height()
        ##height = cs.height() + self._status_and_tool_height
        ##self.window.resize(cs.width(), height)
        ##
        # self.window.setCentralWidget(self.canvas)

        if mpl.is_interactive():
            self.window.show()

        def notify_axes_change(fig):
            # This will be called whenever the current axes is changed
            self.window.setCurrentWidget(self.widget)
            if self.toolbar is not None:
                self.toolbar.update()
        self.canvas.figure.add_axobserver(notify_axes_change)
开发者ID:VirtualPlants,项目名称:openalea,代码行数:53,代码来源:mplwidget.py


示例19: __init__

    def __init__(self, canvas, num):
        print ("new figure manager")
        FigureManagerBase.__init__(self, canvas, num)
        self.canvas = canvas

        # Give the keyboard focus to the figure instead of the
        # manager; StrongFocus accepts both tab and click to focus and
        # will enable the canvas to process event w/o clicking.
        # ClickFocus only takes the focus if the window has been
        # clicked on. 
        # http://qt-project.org/doc/qt-4.8/qt.html#FocusPolicy-enum or
        # http://doc.qt.digia.com/qt/qt.html#FocusPolicy-enum
        self.canvas.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.canvas.setFocus()
开发者ID:dmarcbriers,项目名称:cytoflow,代码行数:14,代码来源:matplotlib_backend.py


示例20: __init__

    def __init__(self, canvas, num):
        FigureManagerBase.__init__(self, canvas, num)
        title = "Figure %d" % num
        _macosx.FigureManager.__init__(self, canvas, title)
        if rcParams['toolbar'] == 'toolbar2':
            self.toolbar = NavigationToolbar2Mac(canvas)
        else:
            self.toolbar = None
        if self.toolbar is not None:
            self.toolbar.update()

        if matplotlib.is_interactive():
            self.show()
            self.canvas.draw_idle()
开发者ID:Carreau,项目名称:matplotlib,代码行数:14,代码来源:backend_macosx.py



注:本文中的matplotlib.backend_bases.FigureManagerBase类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python backend_bases.GraphicsContextBase类代码示例发布时间:2022-05-27
下一篇:
Python backend_bases.FigureCanvasBase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap