当前位置: 首页>>代码示例>>Python>>正文


Python NavigationToolbar2QT.setSizePolicy方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.setSizePolicy方法的具体用法?Python NavigationToolbar2QT.setSizePolicy怎么用?Python NavigationToolbar2QT.setSizePolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4.NavigationToolbar2QT的用法示例。


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

示例1: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setSizePolicy [as 别名]
        def __init__(self):
            Qt.QMainWindow.__init__(self, None)
            #                            "application main window",
            #                            Qt.WType_TopLevel | Qt.WDestructiveClose)

            self.file_menu = Qt.QMenu("&File", self)
            self.file_menu.addAction("&Quit", self.fileQuit, Qt.Qt.CTRL + Qt.Qt.Key_Q)
            self.menuBar().addMenu(self.file_menu)

            self.help_menu = Qt.QMenu("&Help", self)
            self.menuBar().addSeparator()
            self.menuBar().addMenu(self.help_menu)

            self.help_menu.addAction("&About", self.about)

            self.main_widget = Qt.QWidget(self)

            l = Qt.QVBoxLayout(self.main_widget)
            sc = MyPylabPlotter(self.main_widget, dpi=100)
            toolbar = NavigationToolbar(sc, self.main_widget)
            toolbar.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed)
            l.addWidget(sc)
            l.addWidget(toolbar)

            self.main_widget.setFocus()
            self.setCentralWidget(self.main_widget)

            # Produce a plot that is contained in MyPylabPlotter
            sc.demo_pythonic_matplotlib()
            # Produce a plot that is separate from MyPylabPlotter
            sc.demo_pylab_figure()
开发者ID:ska-sa,项目名称:meqtrees-timba,代码行数:33,代码来源:pylab_plotter.py

示例2: init_plots

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setSizePolicy [as 别名]
    def init_plots(self):
        """ Initialize plots used in plugin """
        self.plot_dock = QtGui.QDockWidget('TSTools Plots',
                                           self.iface.mainWindow())
        self.plot_dock.setObjectName('TSTools Plots')

        settings.plot_dirty = []
        for plot in plots.plots:
            self.plots.append(plot(self.iface))
            settings.plot_dirty.append(False)

        self.plot_tabs = QtGui.QTabWidget(self.plot_dock)

        @QtCore.pyqtSlot(int)
        def tab_changed(idx):
            """ Updates current tab index & re-plots if needed """
            settings.plot_current = idx
            if settings.plot_dirty[idx]:
                self.plots[idx].plot()
                settings.plot_dirty[idx] = False
        self.plot_tabs.currentChanged.connect(tab_changed)

        for plot in self.plots:
            widget = QtGui.QWidget()
            layout = QtGui.QHBoxLayout()
            nav = NavigationToolbar(plot, widget, coordinates=False)
            nav.setOrientation(QtCore.Qt.Vertical)

            nav.setSizePolicy(QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.Fixed)
            plot.setSizePolicy(QtGui.QSizePolicy.Preferred,
                               QtGui.QSizePolicy.Preferred)

            layout.addWidget(nav)
            layout.addWidget(plot)

            widget.setLayout(layout)
            self.plot_tabs.addTab(widget, plot.__str__())

        self.plot_dock.setWidget(self.plot_tabs)
        self.iface.addDockWidget(QtCore.Qt.BottomDockWidgetArea,
                                 self.plot_dock)
开发者ID:ceholden,项目名称:TSTools,代码行数:44,代码来源:tstools.py

示例3: PylabPlotter

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setSizePolicy [as 别名]

#.........这里部分代码省略.........
                self.data_list.append(self._rec)
                self.data_list_labels.append(self.label)
                if len(self.data_list_labels) > self.max_list_length:
                    del self.data_list_labels[0]
                    del self.data_list[0]
                if len(self.data_list) != self.data_list_length:
                    self.data_list_length = len(self.data_list)
                if self.data_list_length > 1:
                    _dprint(3, "calling adjust_selector")
                    self.adjust_selector()

    def process_data(self):
        """ process the actual record structure associated with a Cache result """
        process_result = False
        # are we dealing with an pylab result?
        if self._rec.has_key("plotdefs"):
            self.create_layout_stuff()
            self.show_pylab_plot()
            process_result = True

        # enable & highlight the cell
        self.enable()
        self.flash_refresh()
        _dprint(3, "exiting process_data")
        return process_result

    def replay_data(self, data_index):
        """ call to redisplay contents of a result record stored in 
        a results history buffer
    """
        if data_index < len(self.data_list):
            self._rec = self.data_list[data_index]
            self.label = self.data_list_labels[data_index]
            self.results_selector.setLabel(self.label)
            process_result = self.process_data()

    def show_pylab_plot(self, store_rec=True):
        """ process incoming data and attributes into the
        appropriate type of plot """

        # if we are single stepping through requests, Oleg may reset the
        # cache, so check for a non-data record situation
        if store_rec and isinstance(self._rec, bool):
            return

        pylab_record = self._rec.plotdefs
        if not self._pylab_plotter is None:
            #     self._pylab_plotter.reparent(Qt.QWidget(), 0, Qt.QPoint())
            self._pylab_plotter.setParent(Qt.QWidget())
            self._pylab_plotter = None
        if not self._toolbar is None:
            #     self._toolbar.reparent(Qt.QWidget(), 0, Qt.QPoint())
            self._toolbar.setParent(Qt.QWidget())
            self._toolbar = None
        if self._pylab_plotter is None:
            self._pylab_plotter = MyPylabPlotter(parent=self.layout_parent)
            self.layout.addWidget(self._pylab_plotter, 1, 0)
            self._pylab_plotter.show()
        if self._toolbar is None:
            self._toolbar = NavigationToolbar(self._pylab_plotter, self.layout_parent)
            self._toolbar.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed)
            self.layout.addWidget(self._toolbar, 0, 0)
            self._toolbar.show()
        self._pylab_plotter.make_plot(pylab_record)

    # end show_pylab_plot()

    def set_results_buffer(self, result_value):
        """ callback to set the number of results records that can be
        stored in a results history buffer 
    """
        if result_value < 0:
            return
        self.max_list_length = result_value
        if len(self.data_list_labels) > self.max_list_length:
            differ = len(self.data_list_labels) - self.max_list_length
            for i in range(differ):
                del self.data_list_labels[0]
                del self.data_list[0]

        if len(self.data_list) != self.data_list_length:
            self.data_list_length = len(self.data_list)

        self.show_pylab_plot(store_rec=False)

    def adjust_selector(self):
        """ instantiate and/or adjust contents of ResultsRange object """
        if self.results_selector is None:
            self.results_selector = ResultsRange(self.layout_parent)
            self.results_selector.setMaxValue(self.max_list_length)
            self.results_selector.set_offset_index(0)
            self.results_selector.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)
            self.layout.addWidget(self.results_selector, 2, 0)
            self.results_selector.show()
            QObject.connect(self.results_selector, PYSIGNAL("result_index"), self.replay_data)
            QObject.connect(self.results_selector, PYSIGNAL("adjust_results_buffer_size"), self.set_results_buffer)
        self.results_selector.set_emit(False)
        self.results_selector.setRange(self.data_list_length - 1)
        self.results_selector.setLabel(self.label)
        self.results_selector.set_emit(True)
开发者ID:ska-sa,项目名称:meqtrees-timba,代码行数:104,代码来源:pylab_plotter.py


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