如何将 .ui 文件转换为 .py 文件

2024-02-15

这个.ui 文件是由Qt Designer 制作的。这只是一个简单的用户界面。

我浏览过的网站上执行此操作的所有命令或代码均不适用于 Windows。


pyuic 工具在所有平台上的工作方式完全相同:

C:\>pyuic4 -h
Usage: pyuic4 [options] <ui-file>

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -p, --preview         show a preview of the UI instead of generating code
  -o FILE, --output=FILE
                        write generated code to FILE instead of stdout
  -x, --execute         generate extra code to test and display the class
  -d, --debug           show debug output
  -i N, --indent=N      set indent width to N spaces, tab if N is 0 [default: 4]
  -w, --pyqt3-wrapper   generate a PyQt v3 style wrapper

  Code generation options:
    --from-imports      generate imports relative to '.'
    --resource-suffix=SUFFIX
                        append SUFFIX to the basename of resource files
                        [default: _rc]

我怀疑“它不起作用”的原因是您尝试转换的 .ui 文件不在当前目录中。所以你需要先 cd 到该目录:

    C:\>cd C:\path\to\my\ui\files

然后运行 ​​pyuic:

    C:\path\to\my\ui\files\>pyuic4 -o ui_form.py form.ui
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将 .ui 文件转换为 .py 文件 的相关文章

随机推荐