我如何知道另一个 window 是否已关闭?

How do i know if another window is closed?

所以,我需要在 Another Window 关闭后更新 MainWindow 中的 ComboBox。这是打开另一个按钮的功能 window

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)

这里还有一个WindowWindow

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()不会执行

Nvm,通过将 AnotherWindow 更改为 QDialog 并将 self.InputClass.show() 更改为 self.InputClass.exec_()

来解决它