关于python:pyside-uic在哪里?

Where is pyside-uic?

我正在尝试使用Qt Designer和pyside-uic mydesign.ui> design.py

但是,该程序不存在。我在python 2.7下查看了站点包,然后看到:
pyside-lupdate.exe
pyside-rcc.exe

和许多其他程序,但是没有pyside-uic.exe这样的东西……为什么?为什么安装包中没有它?我在哪里得到的?


如果您使用自制软件安装了PySide,则还需要安装pyside-tools软件包以获取以下命令行工具:

1
$ brew install pyside-tools

您应该看到/Python27/Scripts/pyside-uic.exe。但是我想知道为什么它不可见(不可执行)。也许是package问题(权限等)。您可以尝试使用完整路径来调用它。


当我使用conda安装时,py-uic.exe没有解压缩。通过卸载并使用pip解决了该问题。

1
>pip install pyside

对于Mac,它对我运行以下命令(需要安装macports)有效:

1
sudo port install py27-pyside-tools

它安装在我的Python 2.7环境中。
希望对您有所帮助。


由于已经过去了几年,并且有些问题已经解决:我想官方的答案应该是:

使用uic.exe!但是如何?

因此,尽管官方文档仍然缺少任何信息,但是您现在可以使用通过pip install PySide2获得的PySide2软件包附带的可执行文件直接将.ui文件编译为Python。这是您的写法:

1
uic.exe -g python your_design.ui -o your_design_ui.py

其中your_design.ui是Qt Designer文件,而your_design_ui.py是要生成的目标Python文件。 Voilà!

顺便说一句:这是uic -?

的帮助

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
C:\\Python38\\Lib\\site-packages\\PySide2>uic.exe -h
Usage: uic.exe [options] [uifile]
Qt User Interface Compiler version 5.15.0

Options:
-?, -h, --help                Displays help on commandline options.
--help-all                    Displays help including Qt specific options.
-v, --version                 Displays version information.
-d, --dependencies            Display the dependencies.
-o, --output <file>           Place the output into <file>
-a, --no-autoconnection       Do not generate a call to
                                QObject::connectSlotsByName().
-p, --no-protection           Disable header protection.
-n, --no-implicit-includes    Disable generation of #include-directives.
-s, --no-stringliteral        Deprecated. The use of this option won't take
                                any effect.
--postfix <postfix>           Postfix to add to all generated classnames.
--tr, --translate <function>  Use <function> for i18n.
--include <include-file>      Add #include <include-file> to <file>.
-g, --generator <python|cpp>  Select generator.
--idbased                     Use id based function for i18n
--from-imports                Python: generate imports relative to '
.'

Arguments:
[uifile]                      Input file (*.ui), otherwise stdin.

万一有人需要,对于Ubuntu 18.04,我需要先安装pyside-tools软件包。希望有帮助。

1
sudo apt-get install pyside-tools