我希望我的代碼通過顯示qtwidget然後運行forloop, 運行,但它運行forloop然後向我顯示我的小部件。爲什麼是這樣?PyQt運行時問題
class tes(QWidget):
def __init__(self):
super(tes, self).__init__()
self.initUI()
for i in range (1000000):
print("s")
def initUI(self):
t = QTableWidget(8,8,self)
self.show()
self.resize(1000,1000)
t.setGeometry(0,0,500,500)
t.show()
def main():
app = QApplication(sys.argv)
t = tes()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
這是因爲「顯示」出現在'app.exec _()'行(即主循環啓動時)。我想你需要澄清你正在嘗試做什麼。 – Avaris 2012-03-08 17:36:13