内核(Python 3.9.7)'使用pyqt5时死亡

发布于 2025-01-31 12:32:18 字数 1022 浏览 2 评论 0原文

我正在使用VSCODE上的Jupyter笔记本,而我是PYQT5的新手。当我运行这些代码行时,我会收到此错误消息

“”

我尝试重新启动内核,并且每次一次工作一次但也不完全显示小部件。 是输出的屏幕截图

“”

ps,我在Windows 10 16 GB RAM 64 bit上使用Anaconda 3和Python 3

这 我的代码:

import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QWidget, QApplication, QLineEdit, QTableWidget, QStackedWidget
from PyQt5.QtCore import * 

class welcomescreen(QDialog):
    def __init__(self):
        super(welcomescreen,self).__init__()
        loadUi("welcome.ui", self)



# main
app = QApplication(sys.argv)

if app is None:
    app = QtWidgets.QApplication(sys.argv)
    
acceuil=welcomescreen() #object from the class above
widget=QStackedWidget()
widget.addWidget(acceuil)
widget.setFixedHeight(850)
widget.setFixedWidth(1200)
widget.show()
try:
    sys.exit(app.exec_())
except:
    print("Exiting")

I am using Jupyter Notebook on Vscode and I'm new to PyQt5. When I run these lines of code, I got this Error message

I tried restarting the kernel and it only works once each time it but doesn't display the widget fully either. Here's a screenshot of the output

PS, I am using Anaconda 3 and Python 3 on Windows 10 16 GB RAM 64 bit

And here's my code:

import sys
from PyQt5.uic import loadUi
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QDialog, QWidget, QApplication, QLineEdit, QTableWidget, QStackedWidget
from PyQt5.QtCore import * 

class welcomescreen(QDialog):
    def __init__(self):
        super(welcomescreen,self).__init__()
        loadUi("welcome.ui", self)



# main
app = QApplication(sys.argv)

if app is None:
    app = QtWidgets.QApplication(sys.argv)
    
acceuil=welcomescreen() #object from the class above
widget=QStackedWidget()
widget.addWidget(acceuil)
widget.setFixedHeight(850)
widget.setFixedWidth(1200)
widget.show()
try:
    sys.exit(app.exec_())
except:
    print("Exiting")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文