想要做个定时提醒功能之类的小软件,写了下面的代码,但是只能弹出一次就自动退出了。
[code="python"]
import sys
from PyQt4 import QtGui,QtCore
import time
class MyWidget(QtGui.QWidget):
def init(self, msg, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setFixedSize(200, 120)
self.quit = QtGui.QPushButton(msg, self)
self.quit.setGeometry(62, 40, 75, 30)
self.quit.setFont(QtGui.QFont("Times", 18, QtGui.QFont.Bold))
self.connect(self.quit, QtCore.SIGNAL("clicked()"),
QtGui.qApp, QtCore.SLOT("quit()"))
def msgshow(msg):
app = QtGui.QApplication(sys.argv)
widget = MyWidget(msg)
widget.show()
sys.exit(app.exec_())
while True:
msgshow('haah')
time.sleep(3)
[/code]
不知道问题出在哪里呢?
谢谢