The PyQt5 window closes

0

I just started learning PyQt5 and the following code shows no error but when I run it the window quickly opens and closes:

import sys 
import pandas as pd
import matplotlib.pyplot as plt
from PyQt5 import uic, QtWidgets

qtCreatorFile = "matplot.ui"

Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)

class MyApp(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self):
        QtWidgets.QMainWindow.__init__(self)
        Ui_MainWindow.__init__(self)
        self.setupUi(self)

        self.boton1.clicked.connect(self.getCSV)
        self.boton2.clicked.connect(self.plot)

    def getCSV(self):
        filePath,_ = QtWidgets.QFileDialog.getOpenFileName(self, 'Open file', '/Users')
        if filePath != "":
            print ("Dirección",filePath)
            self.df = pd.read_csv(str(filePath))

    def plot (self): 
        x=self.df['col1']
        y=self.df['col2']
        plt.plot(x,y)
        plt.show
        estad_st="Estadisticas de col2: "+str(self.df['col'].describe())
        self.resultado.selfText(stad_st)            

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = MyApp()
    window.show()
    
asked by Juan Pablo 17.08.2018 в 03:07
source

0 answers