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


Python FigureCanvasQTAgg.close方法代码示例

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


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

示例1: Main

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Main(QMainWindow, Ui_MainWindow) :
    def __init__(self, ) :
        super(Main, self).__init__()
        self.setupUi(self)
        
        self.thisDir = os.path.dirname(os.path.abspath(__file__))
        self.btOpenImage.clicked.connect(self.openImage)

        fig = Figure()
        
        self.canvas = FigureCanvas(fig)
        self.canvasGraph.addWidget(self.canvas)
        self.canvas.draw()
                      
        return

    def openImage(self) :
        texto = 'Escolha uma imagem'
        path = QtGui.QFileDialog.getOpenFileNameAndFilter(self,
                                                          texto,
                                                          self.thisDir,
                                                          "Images (*.png *.jpg)")
                                                    
        datafile = cbook.get_sample_data(str(path[0]))
        img = imread(datafile)

        self.updateCanvas(self.initializeCanvas(img))

        return

    def initializeCanvas(self, img) :

        fig = Figure()
        fig.clear()
        Graph = fig.add_subplot(111)
        Graph.imshow(img, zorder=0, extent=[0.0, 1.0, 0.0, 1.0])
       
        return fig
        
    def updateCanvas(self, fig) :
        self.canvasGraph.removeWidget(self.canvas)
        self.canvas.close()
        
        self.canvas = FigureCanvas(fig)
        self.canvasGraph.addWidget(self.canvas)
        self.canvas.draw()

        def onclick(event):
            x, y = event.xdata, event.ydata
            print x, y
         
        self.canvas.mpl_connect('button_press_event', onclick)
        
        return  
开发者ID:alexandrecmaciel,项目名称:Interfaces-graficas-Python-Qt,代码行数:56,代码来源:versao003+(shared+ver.).py

示例2: Mpl

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Mpl(QtGui.QWidget, Ui_Form):
    def __init__(self, fig_dict, name_list):
        super(Mpl, self).__init__()
        self.setupUi(self)
        self.fig_dict = fig_dict
        self.name_list = name_list
        self.index = 0

        self.btnBack.clicked.connect(self.back)
        self.btnForward.clicked.connect(self.forward)

        self.comboBoxSelect.addItems(self.name_list)
        self.comboBoxSelect.setCurrentIndex(self.index)
        self.comboBoxSelect.activated.connect(self.select)
        
        if self.fig_dict and self.name_list:
            fig = self.fig_dict[self.name_list[self.index]]
        else:
            fig = Figure()
        self.addmpl(fig)

    def changefig(self,):
        self.comboBoxSelect.setCurrentIndex(self.index)
        fig = self.fig_dict[self.name_list[self.index]]
        self.rmmpl()
        self.addmpl(fig)

    def addmpl(self, fig):
        self.canvas = FigureCanvas(fig)
        # self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Expanding)
        self.ltMPL.addWidget(self.canvas)
        self.canvas.draw()
        self.toolbar = NavigationToolbar(self.canvas, 
                self.wgtToolbox, coordinates=True)
        self.ltToolbox.addWidget(self.toolbar)

    def rmmpl(self,):
        self.ltMPL.removeWidget(self.canvas)
        self.canvas.close()
        self.ltToolbox.removeWidget(self.toolbar)
        self.toolbar.close()

    def back(self):
        self.index = self.index-1 if self.index!=0 else len(self.name_list)-1
        self.changefig()

    def forward(self):
        self.index = self.index+1 if self.index!=len(self.name_list)-1 else 0
        self.changefig()

    def select(self):
        self.index = self.comboBoxSelect.currentIndex()
        self.changefig()
开发者ID:sig-app,项目名称:PlotViewer,代码行数:55,代码来源:MplCtrl.py

示例3: Main

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Main(QMainWindow, Ui_MainWindow):
    def __init__(self, ):
        super(Main, self).__init__()
        self.setupUi(self)
        self.fig_dict = {}

        self.mplfigs.itemClicked.connect(self.changefig)

        fig = Figure()
        self.addmpl(fig)

    def changefig(self, item):
        text = item.text()
        self.rmmpl()
        self.addmpl(self.fig_dict[text])

    def addfig(self, name, fig):
        self.fig_dict[name] = fig
        self.mplfigs.addItem(name)

    def addmpl(self, fig):
        self.canvas = FigureCanvas(fig)
        self.mplvl.addWidget(self.canvas)
        self.canvas.draw()
        self.toolbar = NavigationToolbar(self.canvas, 
                self.mplwindow, coordinates=True)
        self.mplvl.addWidget(self.toolbar)
# This is the alternate toolbar placement. Susbstitute the three lines above
# for these lines to see the different look.
#        self.toolbar = NavigationToolbar(self.canvas,
#                self, coordinates=True)
#        self.addToolBar(self.toolbar)

    def rmmpl(self,):
        self.mplvl.removeWidget(self.canvas)
        self.canvas.close()
        self.mplvl.removeWidget(self.toolbar)
        self.toolbar.close()
开发者ID:3WiseMen,项目名称:python,代码行数:40,代码来源:custommpl.py

示例4: Main

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Main(QMainWindow, Ui_MainWindow):

    # Define plate arrays as global variables to be able use them elsewhere in the program.
    global w_plate
    global mx_plate
    global my_plate
    global qx_plate
    global qy_plate

    def __init__(self, ):
        super(Main, self).__init__()
        self.setupUi(self)

        self.btnPlot.setStyleSheet('color: red')
        self.textEdit.setTextColor(QtGui.QColor("magenta"))

        # Check deflections radio button by default
        self.deflections_radio.setChecked(False)

        # Creating a QButtonGroup and adding the plot options ratio buttons.
        # This will be used to make sure new results are plotted every time the solve button is pressed.
        # Otherwise, if the deflections radio button is already selected, new run won't plot results.
        self.group = QtGui.QButtonGroup()
        self.group.addButton(self.deflections_radio)
        self.group.addButton(self.mx_radio)
        self.group.addButton(self.my_radio)
        self.group.addButton(self.qx_radio)
        self.group.addButton(self.qy_radio)
        self.plot_options_group.setEnabled(False)

        self.infoLabel.setStyleSheet('color: blue')
        self.infoLabel.setText('  Theory of Plates and Shells\n' +
                               '  Süleyman Muti\n' +
                               '  Spring 2016')

        self.btnPlot.clicked.connect(lambda: self.fdm())
        self.deflections_radio.toggled.connect(lambda: self.deflections_radio_checked())
        self.mx_radio.toggled.connect(lambda: self.mx_radio_checked())
        self.my_radio.toggled.connect(lambda: self.my_radio_checked())
        self.qx_radio.toggled.connect(lambda: self.qx_radio_checked())
        self.qy_radio.toggled.connect(lambda: self.qy_radio_checked())

    def addmpl(self, fig):
        self.canvas = FigureCanvas(fig)
        self.mplvl.addWidget(self.canvas)
        self.canvas.draw()
        self.toolbar = NavigationToolbar(self.canvas,
                                         self.mplwindow, coordinates=True)
        self.mplvl.addWidget(self.toolbar)

    def rmmpl(self, ):
        self.mplvl.removeWidget(self.canvas)
        self.canvas.close()
        self.mplvl.removeWidget(self.toolbar)
        self.toolbar.close()

    def get_grid_size(self):
        if self.rBtn15x10.isChecked():
            return 15, 1e-6
        if self.rBtn30x20.isChecked():
            return 30, 1e-6
        elif self.rBtn180x120.isChecked():
            return 180, 1e-7
        elif self.rBtn540x360.isChecked():
            return 540, 1e-9

    def deflections_radio_checked(self):
        if self.deflections_radio.isChecked():
            self.rmmpl()
            self.print_plot(w_plate, 'Plate Deflections', 'viridis')

    def mx_radio_checked(self):
        if self.mx_radio.isChecked():
            self.rmmpl()
            self.print_plot(mx_plate, 'Mx Bending Moment', 'plasma')

    def my_radio_checked(self):
        if self.my_radio.isChecked():
            self.rmmpl()
            self.print_plot(my_plate, 'My Bending Moment', 'plasma')

    def qx_radio_checked(self):
        if self.qx_radio.isChecked():
            self.rmmpl()
            self.print_plot(qx_plate, 'Qx Transverse Shear Force', 'inferno')

    def qy_radio_checked(self):
        if self.qy_radio.isChecked():
            self.rmmpl()
            self.print_plot(qy_plate, 'Qy Transverse Shear Force', 'inferno')

    def print_plot(self, array_to_be_plotted, plot_title, colormap):
        a = array_to_be_plotted
        self.rmmpl()
        fig = Figure()
        self.addmpl(fig)
        ax = fig.add_subplot(111)
        cax = ax.imshow(a, cmap=colormap)
        fig.colorbar(cax, shrink=0.6, aspect=5)
        fig.tight_layout()
#.........这里部分代码省略.........
开发者ID:suleymanmuti,项目名称:python-plate-finite-difference,代码行数:103,代码来源:tps_hw.py

示例5: MainWindodw

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class MainWindodw(QMainWindow, Ui_MainWindow):
    """main window of application"""
    def __init__(self):
        super(MainWindodw, self).__init__()
        self.setupUi(self)
        self.isTrigMode = False
        self.isRunMode = False
        self.button_list = [self.run_radio_button,
                            self.trig_radio_button,
                            self.run_push_button]
        self.data = []
        self.freq = []
        self.res = []

        # implement button's function
        self.trig_radio_button.clicked.connect(self.trig_toggled)
        self.run_radio_button.clicked.connect(self.run_toggled)
        self.run_push_button.clicked.connect(self.run_pushed)
        self.stop_push_button.clicked.connect(self.stop_pushed)
        self.saveraw_push_button.clicked.connect(self.saveraw_pushed)
        self.savefft_push_button.clicked.connect(self.savefft_pushed)

        # add empty plot
        fig1 = Figure()
        axfig1 = fig1.add_subplot(111)
        axfig1.plot()
        self.add_rawmpl(fig1)

        fig2 = Figure()
        axfig2 = fig2.add_subplot(111)
        axfig2.plot()
        self.add_fftmpl(fig2)

        thread = QtCore.QThread()
        self.reader = SerialReader()
        self.reader.moveToThread(thread)
        self.reader.sig_status.connect(self.serial_plot)
        self.reader.sig_termino.connect(self.enable_button)

    def add_rawmpl(self, fig):
        self.raw_canvas = FigureCanvas(fig)
        self.vl_raw.addWidget(self.raw_canvas)
        self.raw_canvas.draw()
        self.raw_toolbar = NavigationToolbar(self.raw_canvas,
            self, coordinates=True)
        self.vl_raw.addWidget(self.raw_toolbar)

    def add_fftmpl(self, fig):
        self.fft_canvas = FigureCanvas(fig)
        self.vl_fft.addWidget(self.fft_canvas)
        self.fft_canvas.draw()
        self.fft_toolbar = NavigationToolbar(self.fft_canvas,
            self, coordinates=True)
        self.vl_fft.addWidget(self.fft_toolbar)

    def remove_rawmpl(self):
        self.vl_raw.removeWidget(self.raw_canvas)
        self.raw_canvas.close()
        self.vl_raw.removeWidget(self.raw_toolbar)
        self.fft_toolbar.close()

    def remove_fftmpl(self):
        self.vl_fft.removeWidget(self.fft_canvas)
        self.fft_canvas.close()
        self.vl_fft.removeWidget(self.fft_toolbar)
        self.fft_toolbar.close()

    def trig_toggled(self):
        print('trig is toggled')
        self.isTrigMode = True
        self.isRunMode = False

    def run_toggled(self):
        print('run is toggled')
        self.isTrigMode = False
        self.isRunMode = True

    def run_pushed(self):
        if self.isTrigMode: self.reader.mode = b't'
        elif self.isRunMode: self.reader.mode = b'r'
        else:
            self.errorDialog('Select Mode')
            return
        self.disable_button()
        self.reader.run()
        time.sleep(5)

    def stop_pushed(self):
        self.reader.stop()
        self.reader.serial_close()

    def saveraw_pushed(self):
        if not self.data:
            self.errorDialog('No measurement')
            return
        filepath = QtGui.QFileDialog.getSaveFileName(filter='*.dat')[0]
        with open(filepath, 'w') as f:
            for item in self.data:
                f.write(str(item) + '\n')

#.........这里部分代码省略.........
开发者ID:hdkkato,项目名称:my_arduino_samples,代码行数:103,代码来源:serial_plot.py

示例6: Main

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

#.........这里部分代码省略.........
        elif plotType == '2D Image':
            headerList = ["Dep Var:", "Status:"]
            widgetTypeList = ["QLabel", "QCheckBox"]
            depVarList = [row[0] for row in self.dataChest.getVariables()[1]]
            if depVarName is None:
                depVarName = depVarList[0]
            for ii in range(0,len(headerList)):
                optionsSlice = QtGui.QVBoxLayout()
                label = QtGui.QLabel(self) # widget to log
                label.setText(headerList[ii])
                optionsSlice.addWidget(label)
                for depVar in depVarList:
                    if widgetTypeList[ii] =="QLabel":
                        label = QtGui.QLabel(self) # widget to log
                        label.setText(depVar)
                        optionsSlice.addWidget(label)
                    elif widgetTypeList[ii] =="QCheckBox":
                        checkBox = QtGui.QCheckBox('', self)  # widget to log
                        print "depVarName=", depVarName
                        if depVar == depVarName:
                            checkBox.setCheckState(QtCore.Qt.Checked)
                        checkBox.stateChanged.connect(partial(self.varStateChanged, depVar))
                        optionsSlice.addWidget(checkBox)
                optionsSlice.addStretch(1)
                self.scrollLayout.addLayout(optionsSlice)
            self.scrollLayout.addStretch(1)

    def clearLayout(self, layout):
        # Clear the plotType options layout and all widgets therein.
        for i in reversed(range(layout.count())):
            item = layout.itemAt(i)
            
            if isinstance(item, QtGui.QWidgetItem):
                item.widget().close()
            elif not isinstance(item, QtGui.QSpacerItem):
                self.clearLayout(item.layout())
            # remove the item from layout
            layout.removeItem(item) 

    def varStateChanged(self, name, state):
        # Add/remove variables from current displayed plot.
        if state == QtCore.Qt.Checked:
            self.varsToIgnore.remove(name)
            # Remove old figure, needs garbage collection too.
            self.removeFigFromCanvas()
            self.currentFig = self.figFromFileInfo(self.filePath,
                                                   self.fileName,
                                                   selectedPlotType=self.plotType,
                                                   varsToIgnore =self.varsToIgnore) 
            self.addFigureToCanvas(self.currentFig)
        else: # unchecked
            if name not in self.varsToIgnore:
                self.varsToIgnore.append(name)
            # Remove old figure, needs garbage collection too.
            self.removeFigFromCanvas()
            self.currentFig = self.figFromFileInfo(self.filePath,
                                                   self.fileName,
                                                   selectedPlotType=self.plotType,
                                                   varsToIgnore=self.varsToIgnore)
            self.updatePlotTypeOptions(self.plotType, '')
            self.addFigureToCanvas(self.currentFig)

    def convertPathToArray(self, path):
        if self.root + "/" in path:
            path = path.replace(self.root+"/", '')
        elif self.root in path:
开发者ID:McDermott-Group,项目名称:servers,代码行数:70,代码来源:grapher.py

示例7: Main

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

#.........这里部分代码省略.........
        try:
            self.rowEdit.setValue(int(self.data_dict[text].deviceRow))          
        except ValueError:
            pass
        try:
            self.powerType.setText(str(self.data_dict[text].laserPowerType))          
        except ValueError:
            pass
        try:
            self.powerValue.setText(str(self.data_dict[text].laserPower))          
        except ValueError:
            pass
        try:
            self.columnEdit.setValue(int(self.data_dict[text].deviceCol))          
        except ValueError:
            pass
        try:
            ind = self.deviceType.findText(str(self.data_dict[text].deviceType).strip())        
            self.deviceType.setCurrentIndex(ind)          
        except ValueError:
            pass           
        self.activefig=fig
        self.activeDataSet=self.data_dict[text]

    def addmpl(self, fig):
        self.canvas = FigureCanvas(fig)
        self.mplvl.addWidget(self.canvas)
        self.canvas.draw()
        self.toolbar = NavigationToolbar(self.canvas, self.mplwindow, coordinates=True)
        self.mplvl.addWidget(self.toolbar)
    
    def rmmpl(self,):
        self.mplvl.removeWidget(self.canvas)
        self.canvas.close()
        self.mplvl.removeWidget(self.toolbar)
        self.toolbar.close()
#        self.activefig.canvas.mpl_disconnect(self.cid)
    
#This has to be modified for data types other than a ZI data input
    def adddata(self, name, xyDataClass):
        self.data_dict[name] = xyDataClass
        self.mplfigs.addItem(name)
    
#Clcik on active MPL window    
    def onclick(self, event):
#        print 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(event.button, event.x, event.y, event.xdata, event.ydata)
        print self.activeDataSet.find_nearestx(event.xdata)
#gca can get limits of zoomed widow
    def onFit(self,):
        self.disableForFit()
    
    def fitClick(self, event):
        self.cancelFit.setEnabled(True)
        print 'clicked'
        self.activefig.canvas.mpl_disconnect(self.cid)
        xi,xf = self.activeDataSet.fig.gca().get_xlim()
        xi, xvi = self.activeDataSet.find_nearestx(xi)
        xf, xvf = self.activeDataSet.find_nearestx(xf)
# General to this point, actual fit can vary below        
        x0 = event.xdata
        y0 = event.ydata        
        Q = float(self.QEntry.text())
        sigma=1/(2*Q)
        print xi,xf, [x0,y0,sigma]
        ip=[x0,y0,sigma]
        print self.activeDataSet
开发者ID:davidmiller3,项目名称:plotterGUI,代码行数:70,代码来源:custommpl.py

示例8: Main

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

#.........这里部分代码省略.........
        self.rho_h.setText('%3e' %(v_c.corr_h()) )
        
        self.allxpoints = self.tempxpt
        self.allypoints = self.tempypt

    def _reset(self):
        self.previous_point = []
        self.tempxpt,self.tempypt = [],[]
        self.allxpoints = []
        self.allypoints = []
        self.start_point = []
        self.end_point = []
        self.line = None

        ## remember to right-click before reset if changed frame
        self.ax.lines = []
        self.changefig(self.mplfigs.currentItem())

        self.xst.setValue(0)
        self.yst.setValue(0)
            
    def changefig(self, item):
        text = str(item.text())
        self.rmmpl()
        self.addmpl(self.fig_dict[text], self.fg_dict[text])

    def addmpl(self, fig, fg):
        self.canvas = FigureCanvas(fig)
        self.mplvl.addWidget(self.canvas)
        self.toolbar = NavigationToolbar(self.canvas,
                                         self.mplwindow, coordinates=True)
        self.mplvl.addWidget(self.toolbar)
        self.fg = fg
        
        self.ax = self.fig.add_subplot(111)
        self.canvas.draw()
        self.canvas.setFocusPolicy( Qt.ClickFocus )
        self.canvas.setFocus()
        self.canvas.mpl_connect('button_press_event', self.__button_press_callback)
        
    def rmmpl(self,):
        self.mplvl.removeWidget(self.canvas)
        self.canvas.close()
        self.mplvl.removeWidget(self.toolbar)
        self.toolbar.close()

    def __button_press_callback(self, event):
        if event.inaxes:
            x, y = event.xdata, event.ydata
            self.ax = event.inaxes
            if event.button == 1 and event.dblclick == False:  # If you press the left button, single click
                if self.line == None: # if there is no line, create a line
                    self.line = plt.Line2D([x, x],
                                           [y, y],
                                           marker='o',
                                           color=self.roicolor)
                    self.start_point = [x,y]
                    self.previous_point =  self.start_point
                    self.allxpoints=[x]
                    self.allypoints=[y]
                                                
                    self.ax.add_line(self.line)
                    self.canvas.draw()
                    # add a segment
                else: # if there is a line, create a segment
                    self.line = plt.Line2D([self.previous_point[0], x],
                                           [self.previous_point[1], y],
                                           marker = 'o',color=self.roicolor)
                    self.previous_point = [x,y]
                    self.allxpoints.append(x)
                    self.allypoints.append(y)
                                                                                
                    event.inaxes.add_line(self.line)
                    self.canvas.draw()
            elif ((event.button == 1 and event.dblclick==True) or
                  (event.button == 3 and event.dblclick==False)) and self.line != None: # close the loop and disconnect
                self.canvas.mpl_disconnect(self.__ID2) #joerg
                        
                self.line.set_data([self.previous_point[0],
                                    self.start_point[0]],
                                   [self.previous_point[1],
                                    self.start_point[1]])
                self.ax.add_line(self.line)
                self.canvas.draw()
                self.line = None
                                    
    def getMask(self, ci):
        ny, nx = ci.shape        
        poly_verts = [(self.allxpoints[0], self.allypoints[0])]
        for i in range(len(self.allxpoints)-1, -1, -1):
            poly_verts.append((self.allxpoints[i], self.allypoints[i]))
        
        x, y = np.meshgrid(np.arange(nx), np.arange(ny))
        x, y = x.flatten(), y.flatten()
        points = np.vstack((x,y)).T

        ROIpath = mplPath.Path(poly_verts)
        grid = ROIpath.contains_points(points).reshape((ny,nx))
        
        return grid
开发者ID:Mipanox,项目名称:Astroph,代码行数:104,代码来源:roi_vecr_sf.py

示例9: MainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class MainWindow(QtGui.QMainWindow, OnClick, OnMotion):
    def __init__(self):
        super(MainWindow, self).__init__()
        uic.loadUi("PeakInspector_layout.ui", self)
        self.setWindowTitle("PeakInspector (beta) (c) A.Salykin - Masaryk University - CC-BY-SA 4.0")

        # main variable:
        self.multiple_data_sets = pd.DataFrame()  # Initialise the final dataframe to export to Excel

        self.coordinates = []
        self.area = []
        self.amplitudes = []
        self.amplitude_line_coordinates = []
        self.left_peak_border = []
        self.right_peak_border = []
        self.pickable_artists_pts_AX2 = []
        self.pickable_artists_pts_AX3 = []
        self.pickable_artists_lns_AX3 = []
        self.pickable_artists_fill_AX3 = []
        self.pickable_artists_plb_AX3 = []
        self.pickable_artists_prb_AX3 = []
        self.pickable_artists_lnsP_AX3 = []

        self.left_border = []
        self.right_border = []

        # Connect buttons to class methods:
        self.BtnLoadFile.clicked.connect(self.load_file)
        self.BtnReplot.clicked.connect(self.replot_graph)
        self.chbxDotPickEnable.stateChanged.connect(self.dot_pick_enable)
        self.BtnSaveCurrent.clicked.connect(self.coordinates_analysis)
        self.BtnSaveFullDataset.clicked.connect(self.save_data)
        self.BoxMplPlotStyle.currentIndexChanged.connect(self.mpl_style_change)

        style.use(self.BoxMplPlotStyle.currentText())

        self.BtnLoadFile.setStyleSheet("background-color: #7CF2BD")
        self.BtnReplot.setStyleSheet("background-color: #FAF6F2")
        self.BtnSaveCurrent.setStyleSheet("background-color: #FAF6F2")
        self.BtnSaveFullDataset.setStyleSheet("background-color: #FAF6F2")

        # Initialise figure instance
        self.fig = plt.figure()
        self.show()

    def addmpl(self, ):
        self.canvas = FigureCanvas(self.fig)
        self.toolbar = NavigationToolbar(self.canvas, self.CanvasWidget, coordinates=True)
        self.CanvasLayout.addWidget(self.toolbar)
        self.CanvasLayout.addWidget(self.canvas)
        if self.chbxDotPickEnable.isChecked():
            self.cid_click = self.canvas.mpl_connect('button_press_event', self.on_click)
            self.cid_motion = self.canvas.mpl_connect('motion_notify_event', self.on_motion)
        self.canvas.draw()

    def rmmpl(self, ):  #
        self.canvas.mpl_disconnect(self.cid_click)
        self.canvas.mpl_disconnect(self.cid_motion)
        self.CanvasLayout.removeWidget(self.canvas)
        self.canvas.close()
        self.CanvasLayout.removeWidget(self.toolbar)
        self.toolbar.close()

    def dot_pick_enable(self, ):  # if checked, user can choose peaks
        try:  # if figure and canvas is initiated
            if self.chbxDotPickEnable.isChecked():
                self.cid_click = self.canvas.mpl_connect('button_press_event', self.on_click)
                self.cid_motion = self.canvas.mpl_connect('motion_notify_event', self.on_motion)
            else:
                self.canvas.mpl_disconnect(self.cid_click)
                self.canvas.mpl_disconnect(self.cid_motion)
        except:
            message = MessageBox()
            message.about(self, 'Warning!', "File was not loaded! \n Please be sure that your file has \
                \n 1) 1 or 2 columns; \n 2) check headers, footers and delimeter \n and try again.")

    def load_file(self, ):
        self.BtnLoadFile.setStyleSheet("background-color: #FAF6F2")
        # Check if we already have some file loaded - then remove canvas
        if hasattr(self, 'cid_click'):
            self.rmmpl()

        # Make sure that np data arrays and lists from previous dataset are empty
        self.x = np.empty([])
        self.y = np.empty([])
        self.clear_data()

        name = QtGui.QFileDialog.getOpenFileName(self, 'Open File')
        if not name:
            return self.import_error()

        # get more readable file name for graph title
        try:
            slash_index = self.find_character(name, '/')
            dot_index = self.find_character(name, '.')
            self.graph_name = name[slash_index[-1] + 1:dot_index[-1]]
        except:
            self.graph_name = name[-10:]

        skip_header_rows = self.BoxSkipHeader.value()
#.........这里部分代码省略.........
开发者ID:ASalykin,项目名称:PeakInspector,代码行数:103,代码来源:MainWindow.py

示例10: Main

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Main(QMainWindow,Ui_MainWindow):
    def __init__(self,):
        super(Main,self).__init__()
        self.setupUi(self)
        
        self.actionLoad.triggered.connect(self.loadCfg)
        self.ReadButton.clicked.connect(self.readInData)
        self.UpdateButton.clicked.connect(self.updatePlot)
        self.TimeSlider.valueChanged.connect(self.updatePlot)
        self.TimeSlider.sliderMoved.connect(self.updateSlider)
        self.figs = []
        self.axs = []
        self.updating = False

        self.addmpl(Figure())

    def updateSlider(self):
        self.TimeDisplay.setText(self.strlist[self.TimeSlider.value()])

    def updatePlot(self):
        if not self.updating:
            self.updating = True
            self.rmmpl()
            self.addmpl(self.figs[self.TimeSlider.value()])
            self.updating = False

    def loadCfg(self):
        dlg = QFileDialog()
        dlg.setFilter("Config Files (*.ini)")
        self.inifn = str(dlg.getOpenFileName(self,'Open File','.','Config Files (*.ini)'))
        if(self.inifn):
            text = open(self.inifn,'r')
            self.ConfigBox.setText(text.read())
            text.close()

        #self.settings = QSettings(self.inifn, QSettings.IniFormat) #MAYBE USE QSETTINGS FOR INI READ/WRITE?!?!?

    def addmpl(self,fig):
        self.canvas = FigureCanvas(fig)
        self.mplvl.addWidget(self.canvas)
        self.canvas.draw()

        self.toolbar = NavigationToolbar(self.canvas,
                                         self.mplwindow,
                                         coordinates=True)
        self.addToolBar(self.toolbar)

    def rmmpl(self,):
        self.mplvl.removeWidget(self.canvas)
        self.canvas.close()
        self.mplvl.removeWidget(self.toolbar)
        self.toolbar.close()

    def readInData(self):
        f = open(self.inifn,'w')
        f.write(str(self.ConfigBox.toPlainText()))
        f.close()
        
        gpsloc = str(self.GPSBox.text())
        isrloc = str(self.ISRBox.text())
        asloc = str(self.AllSkyBox.text())
        self.PC = PlotClass(self.inifn,GPSloc=gpsloc,ASloc=asloc,ISRloc=isrloc)
        
        self.strlist = [insertinfo( str(j)+' $tmdy $thmsehms',posix=i[0],posixend=i[1]) for j, i in enumerate(self.PC.Regdict['Time'])]
        self.TimeSlider.setMaximum(len(self.strlist)-1)
        self.TimeSlider.setTracking(False)
        self.TimeSlider.setTickPosition(1)

        self.figs=[]
        self.axs=[]
        for t in range(len(self.strlist)):
            print(self.strlist[t])
            self.figs.append(Figure(figsize=(16,10)))
            self.axs.append(self.figs[t].add_subplot(111))
            m=self.PC.plotmap(self.figs[t],self.axs[t])
            (allhands,cbarsax)=self.PC.plotsingle(m,self.axs[t],self.figs[t],timenum=t,icase=0)
        self.rmmpl()
        self.addmpl(self.figs[0])
开发者ID:jswoboda,项目名称:MahaliPlotting,代码行数:80,代码来源:MahaliGui.py

示例11: Main

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Main(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self, ):
        super(Main, self).__init__()
        self.setupUi(self)
        self.PlotButton.clicked.connect(self.plot)
        self.ClearButton.clicked.connect(self.clear)
        self.SaveButton.clicked.connect(self.save)
        self.QuitButton.clicked.connect(self.quit)
        self.subjectNo = 0;
        self.filter = 0;
        self.param =0;
        self.fig = plt.figure();
        self.a1 = self.fig.add_subplot(121)
        self.a2 = self.fig.add_subplot(122)
        self.cnx = mysql.connector.connect(user='root',password='neuro',database='mohand');
        self.cursor = self.cnx.cursor();

    def addplot(self):
        self.canvas = FigureCanvas(self.fig)
        self.mplvl.addWidget(self.canvas)
        self.canvas.draw()
        self.toolbar = NavigationToolbar(self.canvas, self, coordinates=True)
        self.addToolBar(self.toolbar)

    def rmplot(self):
        self.mplvl.removeWidget(self.canvas)
        self.canvas.close()
        self.mplvl.removeWidget(self.toolbar)
        self.toolbar.close()

    def filterstr(self,x):
        return{
            0: '_fil_',
            1: '_raw_'
            }.get(x)

    def paramstr(self,x):
        return{
            0: 'indexVal',
            1: 'meanReactionTime',
            2: 'meanMovementTime',
            3: 'meanResponseTime',
            4: 'meanMaxVel',
            5: 'meanMaxAcc',
            6: 'meanEPD',
            7: 'meanRealDist',
            8: 'meanTraversedDist',
            9: 'meanPerDev',
            10: 'ovMaxReactionTime',
            11: 'ovMaxMovementTime',
            12: 'ovMaxEPD',
            13: 'ovMaxSpeed',
            14: 'ovMaxAcc'
        }.get(x)

    def daystr(self,x):
        return{
            0: 'baseline',
            1: 'day1',
            2: 'day2',
            3: 'day3',
            4: 'day4',
            5: 'day5'
            }.get(x,'performance')
    
    def plot(self):
        print "plotting graph";
        self.subjectNo = int(self.text_subNo.text());
        self.filter = self.combo_filter.currentIndex();
        self.param = self.combo_param.currentIndex();
        fstr = self.filterstr(self.filter);
        pstr = self.paramstr(self.param);
        rep_data = np.zeros(7);
        ran_data = np.zeros(7);
        for i in range(7):
            s = "select count("+pstr+fstr+"rep) from "+self.daystr(i)+" where subNo="+str(self.subjectNo);
            res=self.cursor.execute(s);
            if(int(self.cursor.fetchone()[0])==1):
                s = "select "+pstr+fstr+"rep from "+self.daystr(i)+" where subNo="+str(self.subjectNo);
                res2 = self.cursor.execute(s);
                rep_data[i] = float(self.cursor.fetchone()[0]);
            s = "select count("+pstr+fstr+"ran) from "+self.daystr(i)+" where subNo="+str(self.subjectNo);
            res=self.cursor.execute(s);
            if(int(self.cursor.fetchone()[0])==1):
                s = "select "+pstr+fstr+"ran from "+self.daystr(i)+" where subNo="+str(self.subjectNo);
                res2 = self.cursor.execute(s);
                ran_data[i] = float(self.cursor.fetchone()[0]);
        self.rmplot();
        
        labels = ['Baseline', 'Day 1', 'Day 2','Day 3','Day 4','Day 5','Performance'];
        self.a1.set_xticklabels(labels);
        self.a2.set_xticklabels(labels);
        self.a1.set_title('Repeated Sequence');
        self.a2.set_title('Random Sequence');
        label_ax = 'Subject '+str(self.subjectNo)+' '+pstr;
        self.a1.plot(rep_data, label=label_ax);
        self.a2.plot(ran_data, label =label_ax);
        leg1 = self.a1.legend(loc='best');
        leg2 = self.a2.legend(loc='best');
        leg1.draggable(state=True);
#.........这里部分代码省略.........
开发者ID:arnaghosh,项目名称:MITACS,代码行数:103,代码来源:plotter_prog.py

示例12: Main

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Main(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self, ):
        QtGui.QMainWindow.__init__(self)
        self.setupUi(self)
        
        icon = QtGui.QIcon(':/Icon.png')
        self.setWindowIcon(icon)
        
        self.coeffWH = CAPTUREHEIGHT/CAPTUREWIDTH
        
        self.objectName = self.objectLine.text()
        
        self.path = PATH
        self.directoryLine.setText(self.path)

        self.camara = CAMARA
        self.camaraLine.setText(self.camara)        
        
        self.status = False
        self.cam = None
        
        self.posSlider.valueChanged.connect(self.posChange)    
        
        self.sizeSlider.valueChanged.connect(self.sizeChange)    
        
        self.brightnessSlider.valueChanged.connect(self.brightnessChange)        
        self.contrastSlider.valueChanged.connect(self.contrastChange)
        self.saturationSlider.valueChanged.connect(self.saturationChange)
        self.hueSlider.valueChanged.connect(self.hueChange)        
        self.gainSlider.valueChanged.connect(self.gainChange)
        self.exposureSlider.valueChanged.connect(self.exposureChange)
        
        self.enable_camara_change.changed.connect(self.enableCamaraChangerAction)
        self.actionSave_in.triggered.connect(self.saveFiles)
        self.actionSave_in.setShortcut('Ctrl+S')
        self.aboutAction.triggered.connect(self.about)
        self.filesListWidget.currentRowChanged.connect(self.updateFileImage)
        
        self.startstopButton.clicked.connect(self.startStop)
        self.captureButton.clicked.connect(self.captureData)
        self.cleanButton.clicked.connect(self.cleanPlot)
        self.resetButton.clicked.connect(self.resetSettings)
        self.getFilesButton.clicked.connect(self.getfiles)
        self.analyzeButton.clicked.connect(self.analyzeImages)
        self.saveButton.clicked.connect(self.saveFiles)
        self.clearFilesButton.clicked.connect(self.clearFiles)
        self.comboBox_2.addItem("680 x 480")
        self.comboBox_2.addItem("1280 x 720")
#        self.comboBox_2.addItem("1920 x 1080")
         
        self.comboBox_2.activated[str].connect(self.resolutionBox)
        
        self.canvas = None
        self.filenames = []
        self.imagesFig = None
        self.namesOnly = []
        self.plot = None
        
    def enableCamaraChangerAction(self):
        value = self.enable_camara_change.isChecked()
        self.camaraLine.setEnabled(value)

    def startStop(self):
        self.camaraLine.setEnabled(False)
        if self.status:
            if self.cam != None:
                self.cam.closeInput()
                self.timer.stop()
                self.cam = None
            self.status = not self.status
            self.statusLabel.setText("Stopped")
            self.statusLabel.setStyleSheet('color: red')         
        else:
            self.status = not self.status
            self.videoStream()
            self.update()
            if self.cam != None:
                self.statusLabel.setText("Streaming")
                self.statusLabel.setStyleSheet('color: green')
            else:
                self.status = True
        
        if self.enable_camara_change.isChecked():
            self.enable_camara_change.setChecked(False)
        
    def videoStream(self):
        self.camara = self.camaraLine.text()
        if self.camara.isdigit():
            self.camara = int(self.camara)
        try:
            self.cam = specpy.GuiWindow("Stream", self.camara, self.objectName, STREAMWIDTH, STREAMHEIGHT, PATH, 
                                   POS, SIZE, BRIGHTNESS, CONTRAST, SATURATION, HUE,
                                   GAIN, EXPOSURE, "canvas")
            self.resolutionBox(self.comboBox_2.currentText())
            self.posChange()
            self.sizeChange()
            self.brightnessChange()
            self.contrastChange()
            self.saturationChange()
            self.hueChange()
#.........这里部分代码省略.........
开发者ID:jsbarbosa,项目名称:SpecPy,代码行数:103,代码来源:SpecPySplash.py

示例13: WD

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class WD(QMainWindow,Ui_MainWindow):
    def __init__(self,parent=None):
        QtGui.QWidget.__init__(self,parent)
        self.setupUi(self)
        self.file=open('output.txt','a')
        self.ButtonBack.clicked.connect(self.back1)
        self.radioButton.setChecked(True)
        self.sim=0
        self.true1=0
        
        self.ButtonOn.hide()
        self.ButtonBack.hide()
        self.ButtonPause.hide()
        self.label_5.hide()
        self.interact_game.hide()
        self.game.hide()
        
        self.start.clicked.connect(self.start1)
        self.back.clicked.connect(self.close)
        self.ButtonOn.clicked.connect(self.on)
        
        self.ButtonPause.clicked.connect(self.pause)        
        self.fig_dict={}
        
        self.slider_simulation.hide()
#        self.horizontalSlider.valueChanged.connect(self.initial)
        self.slider_simulation.valueChanged.connect(self.simulation)
        self.fig_dict={}
        self.mplfigs.itemClicked.connect(self.changefig)
        self.fig=plt.figure()
        self.addmpl(self.fig)
        
        self.ButtonDemo_1.clicked.connect(self.demo1)
        self.ButtonDemo_2.clicked.connect(self.demo2)
        self.demo=0
        self.horizontalSlider.valueChanged.connect(self.initial)
        self.pushButton_game.clicked.connect(self.game_call)
        self.pushButton_try.clicked.connect(self.graph_try)
        self.pushButton_return.clicked.connect(self.game_return)
        self.ButtonDiffu.clicked.connect(self.diffusion)
        self.ButtonBackDiffu.clicked.connect(self.backdiffu)
        self.mplwindow_2.hide()
        self.mplwindow_3.hide()
        self.textDiffu.hide()
        self.ButtonBackDiffu.hide()
        self.ButtonDiffu.hide()
        
        showAction=QtGui.QAction('&Authors', self)
        showAction.triggered.connect(self.showAuthors)
        mainMenu=self.menuBar()
        fileMenu=mainMenu.addMenu('&About')
        fileMenu.addAction(showAction)  
        
        self.timer1=QtCore.QTimer(self)
        self.timer2=QtCore.QTimer(self)
        
        self.ani_co=0
        
        file=open('position_02.txt','r')
        lines=file.readlines()
        file.close()
        x=[]
        x1=[]
        x2=[]
        for line in lines:
            p=line.split()
            x.append(float(p[0]))
            x1.append(float(p[1]))
            x2.append(float(p[5]))
        xv=np.array(x)
        xv1=np.array(x1)
        xv2=np.array(x2)
        
        self.rmmpl()
        self.fig=plt.figure()
        axf=self.fig.add_subplot(111)
        axf.set_xlabel('$x/a_{ho}$',fontsize=17)
        axf.set_ylabel('density $|\psi|^2 a_{ho}$',fontsize=14)
        axf.fill_between(xv,0,xv1,label='$R-Space$',facecolor='blue',alpha=0.5)
        axf.fill_between(xv,0,xv2,label='$K-Space$',facecolor='yellow',alpha=0.5)
        axf.set_xlim([-20,20])
        axf.set_title('Wave Packet')
        axf.legend()
        self.addmpl(self.fig) 
        
    def initial(self):
        file=open('initial2.txt','r')
        lines=file.readlines()
        file.close()
        for i in range(0,16):
            globals()['x%s' %i]=[]
        for line in lines:
            p=line.split()
            for i in range(0,16):
                globals()['x%s' %i].append(float(p[i-1]))
        for i in range(0,16):
                globals()['xv%s' %i]=np.array(globals()['x%s' %i])       
        value=self.horizontalSlider.value()
        
        for i in range(3,16):
#.........这里部分代码省略.........
开发者ID:IvanMorera,项目名称:ultracoldUB,代码行数:103,代码来源:WD_interfaz.py

示例14: MatplotlibWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class MatplotlibWidget(QtGui.QWidget):
    '''Base class for matplotlib widgets
    '''
    def __init__(self, parent):
        '''Inits matplotlib widget.
        
        Args:
            parent: A Parent class object.
        '''
        super().__init__()
        self.main_frame = parent
        self.dpi = 75
        self.show_axis_ticks = True
        self.__create_frame()


    def __create_frame(self):
        self.fig = Figure((5.0, 3.0), dpi=self.dpi)
        self.fig.patch.set_facecolor("white")
        self.canvas = FigureCanvas(self.fig)
        self.canvas.manager = MockManager(self.main_frame)
        self.canvas.setParent(self.main_frame)
        self.axes = self.fig.add_subplot(111)
        
        self.mpl_toolbar = NavigationToolbar(self.canvas, self.main_frame)
        hbox = QtGui.QHBoxLayout()
        
        self.main_frame.ui.matplotlib_layout.addWidget(self.canvas)
        self.main_frame.ui.matplotlib_layout.addWidget(self.mpl_toolbar)
        self.main_frame.ui.matplotlib_layout.addLayout(hbox)


    def fork_toolbar_buttons(self):
        '''Remove figure options & subplot config that might not work properly.
        '''
        try:
            self.mpl_toolbar.removeAction(self.mpl_toolbar.children()[21]) 
            self.mpl_toolbar.removeAction(self.mpl_toolbar.children()[17])
        except:
            pass  # Already removed
    
    
    def remove_axes_ticks(self):
        '''Remove ticks from axes.
        '''
        if not self.show_axis_ticks:
            for tick in self.axes.yaxis.get_major_ticks():
                tick.label1On = False
                tick.label2On = False
            for tick in self.axes.xaxis.get_major_ticks():
                tick.label1On = False
                tick.label2On = False
                
                
    def delete(self):
        '''Delete matplotlib objects.
        '''
        self.axes.clear()  # Might be useless with fig.clf()
        self.canvas.close()
        self.fig.clf()
        self.close()
        
        del self.fig
        del self.canvas
        del self.axes
        
        import gc
        gc.collect()
开发者ID:Caffeinomane,项目名称:potku,代码行数:70,代码来源:MatplotlibWidget.py

示例15: Window

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import close [as 别名]
class Window(QtGui.QMainWindow):
    r""" A mainwindow object for the GUI display. Inherits from QMainWindow."""

    def __init__(self):
        super(Window, self).__init__()
        self.interface()

    def interface(self):
        r""" Contains the main window interface generation functionality. Commented where needed."""

        # Get the screen width and height and set the main window to that size
        screen = QtGui.QDesktopWidget().screenGeometry()
        self.setGeometry(0, 0, 800, screen.height())
        self.setMaximumSize(QtCore.QSize(800, 2000))

        # Set the window title and icon
        self.setWindowTitle("WAVE: Weather Analysis and Visualization Environment")
        self.setWindowIcon(QtGui.QIcon('./img/wave_64px.png'))

        # Import the stylesheet for this window and set it to the window
        stylesheet = "css/MainWindow.css"
        with open(stylesheet, "r") as ssh:
            self.setStyleSheet(ssh.read())
        self.setAutoFillBackground(True)
        self.setBackgroundRole(QtGui.QPalette.Highlight)

        # Create actions for menus and toolbar
        exit_action = QtGui.QAction(QtGui.QIcon('./img/exit_64px.png'), 'Exit', self)
        exit_action.setShortcut('Ctrl+Q')
        exit_action.setStatusTip('Exit application')
        exit_action.triggered.connect(self.close)
        clear_action = QtGui.QAction(QtGui.QIcon('./img/clear_64px.png'), 'Clear the display', self)
        clear_action.setShortcut('Ctrl+C')
        clear_action.setStatusTip('Clear the display')
        clear_action.triggered.connect(self.clear_canvas)
        skewt_action = QtGui.QAction(QtGui.QIcon('./img/skewt_64px.png'), 'Open the skew-T dialog', self)
        skewt_action.setShortcut('Ctrl+S')
        skewt_action.setStatusTip('Open the skew-T dialog')
        skewt_action.triggered.connect(self.skewt_dialog)
        radar_action = QtGui.QAction(QtGui.QIcon('./img/radar_64px.png'), 'Radar', self)
        radar_action.setShortcut('Ctrl+R')
        radar_action.setStatusTip('Open Radar Dialog Box')
        radar_action.triggered.connect(self.radar_dialog)

        # Create the top menubar, setting native to false (for OS) and add actions to the menus
        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        filemenu = menubar.addMenu('&File')
        editmenu = menubar.addMenu('&Edit')
        helpmenu = menubar.addMenu('&Help')
        filemenu.addAction(exit_action)

        # Create the toolbar, place it on the left of the GUI and add actions to toolbar
        left_tb = QtGui.QToolBar()
        self.addToolBar(QtCore.Qt.LeftToolBarArea, left_tb)
        left_tb.setMovable(False)
        left_tb.addAction(clear_action)
        left_tb.addAction(skewt_action)
        left_tb.addAction(radar_action)
        self.setIconSize(QtCore.QSize(30, 30))

        # Create the toolbar, place it on the left of the GUI and add actions to toolbar
        right_tb = QtGui.QToolBar()
        self.addToolBar(QtCore.Qt.RightToolBarArea, right_tb)
        right_tb.setMovable(False)
        right_tb.addAction(clear_action)
        right_tb.addAction(skewt_action)
        right_tb.addAction(radar_action)

        # Create the status bar with a default display
        self.statusBar().showMessage('Ready')

        # Figure and canvas widgets that display the figure in the GUI
        self.figure = plt.figure(facecolor='#2B2B2B')
        self.canvas = FigureCanvas(self.figure)

        # Add subclassed matplotlib navbar to GUI
        # spacer widgets for left and right of buttons
        left_spacer = QtGui.QWidget()
        left_spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        right_spacer = QtGui.QWidget()
        right_spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        self.mpltb = QtGui.QToolBar()
        self.mpltb.addWidget(left_spacer)
        self.mpltb.addWidget(MplToolbar(self.canvas, self))
        self.mpltb.addWidget(right_spacer)
        self.mpltb.setMovable(False)
        self.addToolBar(QtCore.Qt.TopToolBarArea, self.mpltb)

        # Set the figure as the central widget and show the GUI
        self.setCentralWidget(self.canvas)
        self.show()

    def skewt_dialog(self):
        r""" When the toolbar icon for the Skew-T dialog is clicked, this function is executed. Creates an instance of
        the SkewTDialog object which is the dialog box. If the submit button on the dialog is clicked, get the user
        inputted values and pass them into the sounding retrieval call (DataAccessor.get_sounding) to fetch the data.
        Finally, plot the returned data via self.plot.

        Args:
#.........这里部分代码省略.........
开发者ID:Unidata,项目名称:Wave,代码行数:103,代码来源:mainwindow.py


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