如何将 .ui 文件转换为 .py 文件 [英] How to convert a .ui file to .py file

查看:78
本文介绍了如何将 .ui 文件转换为 .py 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

This .ui file is made by Qt Designer. It's just a simple UI.

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

All the commands or codes for doing this on the websites I have looked through are not for windows.

推荐答案

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

The pyuic tool works in exactly the same way on all platforms:

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 到那个目录:

I suspect the reason "it doesn't work" is that the .ui file you are trying to convert is not in the current directory. So you need to cd to that directory first:

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

然后运行 ​​pyuic:

then run pyuic:

    C:\path\to\my\ui\files\>pyuic4 -o ui_form.py form.ui

这篇关于如何将 .ui 文件转换为 .py 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆