我想有一个没有主窗口的应用程序,但有许多小部件一一显示(对话框对我不起作用)。
我有以下代码:
# -*- coding: utf-8 -*-
from PyQt4 import QtCore, QtGui
from start_window import Ui_Form
from second_window import Ui_Form as Ui_Form_Second
class StartForm(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
self.ui.pushButton.clicked.connect(self.button)
def button(self):
secondWindow = SecondForm()
secondWindow.show()
self.hide()
class SecondForm(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form_Second()
self.ui.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
myapp = StartForm()
myapp.show()
sys.exit(app.exec_())
当我按下按钮应用程序关闭。如何将应用程序的执行传递给第二个小部件?