将 .py 转换为 .ui 文件 [英] Converting .py to .ui file

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

问题描述

我们已经知道我们可以使用 pyuic4 轻松地从 ui 转换为 py.

We already know that we can convert from ui to py easily with pyuic4.

可以将 .py(仅包含 pyqt ui 相关内容)代码转换回 .ui.

Is possible to convert .py (that only contains pyqt ui related stuff) code back to .ui.

推荐答案

Qt/PyQt 没有为此提供工具,而且 AFAIK 没有人写过.

Qt/PyQt doesn't come with a tool for that, and AFAIK nobody's written one.

而且很难想象您为什么需要它.只需保留 .ui 文件,永远不要编辑生成的 .py 文件(甚至在运行时使用 uic 动态使用 .ui 文件),您将永远不需要反向转换.

And it's hard to imagine why you'd need it. Just keep the .ui file around, and never edit the generated .py file (or even use the .ui file dynamically at runtime with uic), and you'll never need to reverse-convert.

同时,如果您有一些随机的 PyQt4 代码生成的 GUI 甚至不是由 pyuic4 创建的,则不能保证任何 .ui 可能生成代码.(实际上,您在网上找到的大多数 PyQt 示例都不会以 pyuic4 的方式做事,而且很可能任何其他代码生成器也不会以同样的方式做事 pyuic4 可以.)

Meanwhile, if you've got some random PyQt4 code that generates a GUI that wasn't even created by pyuic4, there's no guarantee that any .ui could possibly generate the code. (In fact, most of the PyQt samples you'll find online don't do things the same way pyuic4 would, and most likely any other code generator will similarly not do things the same way pyuic4 does.)

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

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