我在用PyQt5编写一组代码,需求是创建界面气泡提示时,运行的时候显示空的,没有任何界面出现,请问是什么情况啊?
import sys
from PyQt5.QtWidgets import QWidget,QToolTip,QApplication
from PyQt5.QtGui import QFont
class Example(QWidget):
def init(self):
super().init()
self.initUI()
def initUI(self):
self.setGeometry(300,300,750,450)
self.setWindowTitle('气泡提示')
self.setToolTip('请注意看这里'))
QToolTip.setFont(QFont('Century',10))
self.show()
if name == '__main__':
app=QApplication(sys.argv)
ex=Example()
sys.exit(app.exec_())
最后运行的时候显示:
C:\Users\Administrator\PycharmProjects\pythonProject\pythonProject\pythonProject\pythonProject\chensiqi\venv\Scripts\python.exe C:/Users/Administrator/PycharmProjects/pythonProject/pythonProject/pythonProject/pythonProject/chensiqi/main.py
Process finished with exit code 0
把
sys.exit(app.exec_())
改成
app.exec_()