美文网首页
macOS(Ventural 13.1)环境下PyCharm中p

macOS(Ventural 13.1)环境下PyCharm中p

作者: 望江樵夫 | 来源:发表于2023-01-27 23:04 被阅读0次

1、创建conda虚拟环境

conda create -n env_name python=3.9

2、安装PyQt5

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ pyqt5
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ pyqt5-tools

3、在pycharm中配置外部工具

  • 打开pycharm并选择第一步创建的conda虚拟环境“env_name”为默认python解释器
    打开设置进入外部工具配置页面
    外部工具配置页面
    注意:接下来的配置会使用选中python解释器的安装路径:PyInterpreterDirectory
  • 配置QtDesigner工具(用于编写.ui文件)
    新建QtDesigner工具,配置下图红框中的内容


    QtDesigner配置信息

    Program:

$PyInterpreterDirectory$/../lib/python3.9/site-packages/qt5_applications/Qt/bin/Designer.app/Contents/MacOS/Designer

Arguments:

$FileName$

Working directory:

$ProjectFileDir$
  • 配置pyuic5工具(用于将.ui文件转换为.py文件)
    新建pyuic5工具,配置下图红框中的内容


    pyuic5配置信息

Program:

$PyInterpreterDirectory$/pyuic5

Arguments:

$FileName$ -o $FileNameWithoutExtension$.py -x

Working directory:

$FileDir$
  • 配置pyrcc5工具(用于将.qrc文件转换为.py文件)
    新建pyrcc5工具,配置下图红框中的内容


    pyrcc5配置信息

Program:

$PyInterpreterDirectory$/pyrcc5

Arguments:

$FileName$ -o $FileNameWithoutExtension$_rc.py

Working directory:

$FileDir$

4、使用方法

在对应的文件上右键->External Tools-> QtDesigner


例如编辑ui文件

5、错误解决

macOS下运行pyqt应用出现如下错误:


qt.qpa.fonts: Populating font family aliases took 352 ms. Replace uses of missing font family "Roboto" with one that exists to avoid this cost.

缺少开发使用的Roboto字体,下载安装 Google Roboto 字体即可!
如何在 Windows、Mac 和 Linux 上安装 Google Roboto 字体

相关文章

网友评论

      本文标题:macOS(Ventural 13.1)环境下PyCharm中p

      本文链接:https://www.haomeiwen.com/subject/pixyhdtx.html