专业的编程技术博客社区

网站首页 > 博客文章 正文

进入Python的世界02外篇-Pycharm配置Pyqt6

baijin 2024-08-16 11:39:56 博客文章 10 ℃ 0 评论

为什么这样配置,要开发带UI的python也只能这样了,安装过程如下:

一 安装工具

打开终端:

pip install PyQt6 PyQt6-tools

二 打开设置并汉化

点击plugin,安装汉化插件,如图所示:


安装之后,配置如下:文件-设置-工具-外部工具,如下

三 增加界面设计师的调用

程序:C:\Users\Administrator\anaconda3\Scripts\qt6-tools.exe

实参:designer

工具目录:$FileDir$

四 增加PYQT6转化工具

界面中变量:

程序:C:\Users\Administrator\anaconda3\Scripts\pyuic6.exe

实参:$FileName$ -o $FileNameWithoutExtension$.py

工具目录:$FileDir$

五 测试程序

调用界面设计师

建个mianwindow界面,任意就行,保存

选中刚才的UI文件,右键点PIU6,把UI文件转成了PY文件,如下图所示

新建个main.py文件,内容如下:

class MyMainForm(QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MyMainForm, self).__init__()
        self.setupUi(self)


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    app = QApplication(sys.argv)
    myw = MyMainForm()
    myw.show()
    sys.exit(app.exec())

保存,运行,得到如下效果:

好了,把Pycharm配置好了,可以开心地写程序了

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表