我想在 python 的弹出窗口中显示一条消息......所以我写了这段代码......请检查
import sys
from PyQt4.Qt import *
class MyPopup(QWidget):
def __init__(self):
print "6"
QWidget.__init__(self)
class MainWindow(QMainWindow):
def __init__(self, *args):
print "4"
QMainWindow.__init__(self, *args)
self.cw = QWidget(self)
self.setCentralWidget(self.cw)
self.btn1 = QPushButton("Start Chat", self.cw)
self.btn1.setGeometry(QRect(50, 30, 100, 30))
self.connect(self.btn1, SIGNAL("clicked()"), self.doit)
self.w = None
def doit(self):
print "5"
print "Opening a new popup window..."
self.w = MyPopup()
self.w.setGeometry(QRect(0, 0, 400, 200))
self.w.show()
class App(QApplication):
def __init__(self, *args):
print "3"
QApplication.__init__(self, *args)
self.main = MainWindow()
#self.connect(self, SIGNAL("lastWindowClosed()"), self.byebye )
self.main.show()
#def byebye( self ):
#self.exit(0)
for i in range(1, 5):
if __name__ == "__main__":
print "1"
global app
app = App(sys.argv)
app.exec_()
#main(sys.argv)
else:
print "over"
这里首先循环它的工作,但从第二个循环我得到分段错误......伙计们请帮助我..