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


Python NavigationToolbar2QT.home方法代码示例

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


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

示例1: MainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QT import home [as 别名]
class MainWindow(QtGui.QMainWindow, mw.Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.datalst = []
        self.modellst = []
        self.lstdatamodel = QtGui.QStandardItemModel(self.listView)
        self.listView.setModel(self.lstdatamodel)
        self.current_lst_index = -1
        self.addButton.clicked.connect(self.add)
        self.removeButton.clicked.connect(self.remove)
        self.actionCalcLSSParameter.triggered.connect(self.calculatelss)
        self.actionAutomaticElutionWindowStretching.triggered.connect(self.calcautelwindowstretch)
        self.actionSelectivityMap.triggered.connect(self.pltselectivitymap)
        self.actionResolutionMap.triggered.connect(self.pltresolutionmap)
        self.actionAbout.triggered.connect(self.about)
        self.actionQuit.triggered.connect(self.quit)
        self.listView.clicked.connect(self.viewmatrix)
        self.toolBox.currentChanged.connect(self.viewmatrix)

        self.zoomButton.clicked.connect(self.zoom)
        self.panButton.clicked.connect(self.pan)
        self.rescaleButton.clicked.connect(self.home)
        self.modelBox.currentIndexChanged.connect(self.gradientanalyser)
        self.doubleSpinBox_1.valueChanged.connect(self.gradientanalyser)
        self.doubleSpinBox_2.valueChanged.connect(self.gradientanalyser)
        self.doubleSpinBox_3.valueChanged.connect(self.gradientanalyser)
        self.doubleSpinBox_4.valueChanged.connect(self.gradientanalyser)
        self.doubleSpinBox_5.valueChanged.connect(self.gradientanalyser)
        self.ColumnLenghtSpinBox.valueChanged.connect(self.gradientanalyser)
        self.CulumnDiameterSpinBox.valueChanged.connect(self.gradientanalyser)
        self.ColumnPorositySpinBox.valueChanged.connect(self.gradientanalyser)

        # Add plot
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # set the layout
        layout_chormatogram = QtGui.QVBoxLayout()
        layout_chormatogram.addWidget(self.canvas)
        self.plotterBox.setLayout(layout_chormatogram)

        # Add selectivity map plot
        #self.figure_smap = plt.figure()
        #self.canvas_smap = FigureCanvas(self.figure_smap)
        #self.toolbar_smap = NavigationToolbar(self.canvas_smap, self)
        #self.toolbar_smap.hide()

        #layout_smap = QtGui.QVBoxLayout()
        #layout_smap.addWidget(self.canvas_smap)
        #self.plotterBox_2.setLayout(layout_smap)

        self.tablemodel = TableModel(self)
        self.tableView.setModel(self.tablemodel)
        self.tableView.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.tableView.customContextMenuRequested.connect(self.openTableMenu)

        # constant parameters
        self.crit_resolution = 1.8
        self.crit_alpha = 1.1

    def openTableMenu(self, position):
        """ context menu event """
        menu = QtGui.QMenu(self)
        exportAction = menu.addAction("Export table as CSV")
        action = menu.exec_(self.tableView.viewport().mapToGlobal(position))

        if action == exportAction:
            fname = QtGui.QFileDialog.getSaveFileName(self, "Save File", "CSV (*.csv)");
            #fname = QtGui.getSaveFileName.getOpenFileName(self, tr('Save File'), )
            self.tablemodel.SaveTable(fname)
        else:
            return


        return


    def keyPressEvent(self, e):
        if (e.modifiers() & QtCore.Qt.ControlModifier):
            if e.key() == QtCore.Qt.Key_C: #copy
                if len(self.tableView.selectionModel().selectedIndexes()) > 0:
                    previous = self.tableView.selectionModel().selectedIndexes()[0]
                    columns = []
                    rows = []
                    for index in self.tableView.selectionModel().selectedIndexes():
                        if previous.column() != index.column():
                            columns.append(rows)
                            rows = []
                        rows.append(str(index.data().toPyObject()))
                        previous = index
                    columns.append(rows)

                    # add rows and columns to clipboard
                    clipboard = ""
                    nrows = len(columns[0])
                    ncols = len(columns)
                    for r in xrange(nrows):
#.........这里部分代码省略.........
开发者ID:gmrandazzo,项目名称:PyLSS,代码行数:103,代码来源:pylss-gui.py

示例2: Window

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

#.........这里部分代码省略.........
        self.get_data()
        self.plot()
        print 'View changed to: ', self.view

    def comboActivated(self, text):
        self.tag = text
        self.data = self.b.getvar(self.tag)
        self.plot()

    def reset_bifrost_obj(self):
        self.b, self.base_name, self.snap_n = get_bifrost_obj(self.fpath,0,self.check_aux.isChecked())
        print self.b.snapvars
        self.get_data()

    def get_data(self):
        self.data = self.b.getvar(self.tag)
        if self.view == 'X-Y':
            self.slide_dimension = 2
        elif self.view == 'X-Z':
            self.slide_dimension = 1
        elif self.view == 'Y-Z':
            self.slide_dimension = 0

        self.slider.setMinimum(0)
        self.slider.setMaximum(self.data.shape[self.slide_dimension]-1)

        if self.slider.value() >= self.data.shape[self.slide_dimension]:
            self.slider.setValue(self.data.shape[self.slide_dimension]-1)
        elif self.slider.value() < 0:
            self.slider.setValue(0)

        self.setCombo()

    def home(self):
        self.toolbar.home()
    def zoom(self):
        self.toolbar.zoom()
    def pan(self):
        self.toolbar.pan()

    def plot(self):
        plt.clf()
        ax = self.figure.add_subplot(111)
        slice_str = '[?]'
        # extension = []
        if self.view == 'X-Y':
            image = self.data[:,:,self.slider.value()]
            slice_str = 'z = %f ' % self.b.z[self.slider.value()]
            ax.set_ylabel('y-direction')
            ax.set_xlabel('x-direction')
            # extension = [0, self.param['mx'], 0, self.param['my']]
        elif self.view == 'X-Z':
            image = self.data[:,self.slider.value(),:]
            slice_str = 'y = %f ' % self.b.y[self.slider.value()]
            ax.set_ylabel('z-direction')
            ax.set_xlabel('x-direction')
            # extension = [0, self.param['mx'], 0, self.param['mz']]
        elif self.view == 'Y-Z':
            image = self.data[self.slider.value(),:,:]
            slice_str = 'x = %f ' % self.b.x[self.slider.value()]
            ax.set_ylabel('z-direction')
            ax.set_xlabel('y-direction')
            # extension = [0, self.param['my'], 0, self.param['mz']]
        # image = np.fliplr(image)
        # image = np.rot90(image,k=3)
        
开发者ID:M1kol4j,项目名称:BQ_t4_Look,代码行数:69,代码来源:bq_t4_look.py


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