您的位置:首页 > 健康 > 养生 > PyQt5学习系列之新项目创建并使用widget

PyQt5学习系列之新项目创建并使用widget

2024/10/6 2:31:46 来源:https://blog.csdn.net/arriettyandray/article/details/139680676  浏览:    关键词:PyQt5学习系列之新项目创建并使用widget

PyQt5学习系列之新项目创建并使用widget

  • 前言
  • 报错
  • 新建项目程序
  • 完整程序
  • 总结


前言

新建项目,再使用ui转py,无论怎么样都打不开py文件,直接报错。


报错

Connected to pydev debugger (build 233.11799.298)

在这里插入图片描述

新建项目程序

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.def print_hi(name):# Use a breakpoint in the code line below to debug your script.print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.# Press the green button in the gutter to run the script.
if __name__ == '__main__':print_hi('PyCharm')# See PyCharm help at https://www.jetbrains.com/help/pycharm/

完整程序

# This is a sample Python script.
import sys# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.from PyQt5.QtWidgets import QWidget, QApplicationimport ImageView
def print_hi(name):# Use a breakpoint in the code line below to debug your script.print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.# Press the green button in the gutter to run the script.
if __name__ == '__main__':app = QApplication(sys.argv)main=QWidget()_ui = ImageView.Ui_Form()_ui.setupUi(main)main.show()print_hi('PyCharm')sys.exit(app.exec_())# See PyCharm help at https://www.jetbrains.com/help/pycharm/

总结

简单记录。

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com