我怎么知道另一个窗口是否关闭?

时间:2018-05-28 15:42:02

标签: python pyqt4 qdialog

因此,我需要在关闭另一个窗口后更新MainWindow中的ComboBox。这是按钮打开另一个窗口的功能

import AnotherWindow as cl

       def inputclass(self):
                self.InputClass = cl.InputWindow()
                self.InputClass.show()
                self.boxclass()

       def boxclass(self):
            self.BoxClass.clear()
            with open('data/ClassSuara.csv','rb') as f :
                reader = csv.reader(f)
                listsuara = list(reader)
            for a in listsuara:
                cek = str(a)
                b = cek[2:-2]
                self.BoxClass.addItem(b)

这里是AnotherWindow Window

class InputWindow(QtGui.QMainWindow, gui.Ui_KelasSuara):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        gui.Ui_KelasSuara.__init__(self)
        self.setupUi(self)
        self.BtnTambah.clicked.connect(self.Tambahkan)

    def Tambahkan(self):
        self.listClass.clear()
        ClassSuara = open('data/ClassSuara.csv','a')
        ClassSuara.write(self.lineClass.text()+'\n')
        ClassSuara.close()

但是在AnotherWindow关闭后,self.boxclass()将不会执行

1 个答案:

答案 0 :(得分:0)

Nvm,通过将AnotherWindow更改为QDialog解决此问题,并将self.InputClass.show()更改为self.InputClass.exec_()