我想顯示在蟒蛇彈出窗口中的消息...所以我寫了這個代碼...請蟒蛇分段錯誤
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"
這裏第一循環的工作,但是從第二回路即時得到細分故障...傢伙請幫幫我..
[這個答案](http://stackoverflow.com/a/12457209/1820106)爲我解決了這個問題。 –