python QAxWidget未执行
问题描述:
我使用QAxWidget与python。直到昨天,下面的代码运行良好。但现在不好。代码结果是 '回归1'python QAxWidget未执行
from PyQt5.QAxContainer import *
class test(QAxWidget):
def __init(self):
super.__init__()
......
test()
下面的代码是一样的
from PyQt5.QAxContainer import *
a = QAxWidget()
所以,我认为PyQt5文件打破了。我卸载Anaconda并安装Anaconda。 但结果是一样的。 我用python idle来运行程序。原来,pyCharm。 但结果是一样的。
帮助我。我该怎么办?请!!
答
试试这个:
from PyQt5.QAxContainer import *
from PyQt5.QtWidgets import *
import os, sys
class MyMainWindow(QAxWidget):
def __init__(self):
QAxWidget.__init__(self)
# < Global Settings >
self.setWindowTitle("Hello")
self.setFixedSize(510, 510)
self.move(400, 30)
# </ Global Settings >
if __name__ == '__main__':
My_Application = QApplication(sys.argv)
MainWindow = MyMainWindow()
MainWindow.show()
sys.exit(My_Application.exec_())
好运...
使用例如运行代码的脚本在一个正常的命令窗口'python.exe test.py'。这应该显示一个python traceback和/或一些qt警告消息。 – ekhumoro
所以我跑Jupyter。和结果是一样的。 jupyter说:“内核看起来已经死了,它会自动重启。”我该怎么办??? – dnjs7292
我解决了!我添加代码'My_Application = QApplication(sys.argv)'因此,它运行良好。谢谢 – dnjs7292