简体   繁体   English

OSX 10.6 上 PyQt 的 Qt 设计器

[英]Qt Designer for PyQt on OSX 10.6

I liked Qt Designer on Windows so much for making GUIs for Python applications (using PyQt4) that I went and tried to install it on my Mac (under OSX 10.6.6).我非常喜欢 Windows 上的 Qt Designer,因为它为 Python 应用程序(使用 PyQt4)制作 GUI,我尝试将它安装在我的 Mac 上(在 OSX 10.6.6 下)。

At this point, I have successfully installed SIP, Qt4, and PyQt4.至此,我已经成功安装了SIP、Qt4和PyQt4。

The PyQt binary installers (for Windows) include a version of Qt Designer that works with PyQt. PyQt 二进制安装程序(适用于 Windows)包括与 PyQt 一起使用的 Qt Designer 版本。 On OSX, there is no binary installer, just source.在 OSX 上,没有二进制安装程序,只有源代码。 So no Qt Designer.所以没有Qt设计师。

The Qt website offers Qt Creator as a download, but as far as I can tell, it requires that you're writing code in C/C++. Qt 网站提供 Qt Creator 作为下载,但据我所知,它要求您使用 C/C++ 编写代码。

Is there a way to make Qt Creator work with PyQt?有没有办法让 Qt Creator 与 PyQt 一起工作? Or is there another GUI designer for PyQt that works on a Mac?或者是否有另一个适用于 Mac 的 PyQt GUI 设计器?

Thanks!谢谢! -Wesley -卫斯理

If you've installed Qt4, then you have Qt Designer.如果您已经安装了 Qt4,那么您就有了 Qt Designer。 If you used the installer from qt.nokia.com, it should be in /Developer/Applications/Qt.如果您使用了 qt.nokia.com 上的安装程序,它应该在 /Developer/Applications/Qt 中。

Qt Designer itself works just fine with PyQt. Qt Designer 本身与 PyQt 配合得很好。 Qt designer just spits out XML describing the UI structure. Qt 设计器只是吐出描述 UI 结构的 XML。 If you were using standard Qt with C++, you would have to run the uic tool to generate C++ from the .ui files.如果您在 C++ 中使用标准 Qt,则必须运行uic工具以从 .ui 文件生成 C++。 Likewise, with PyQt4, you must run pyuic4 on the generated .ui file to create python source from it.同样,对于 PyQt4,您必须在生成的 .ui 文件上运行pyuic4以从中创建 python 源代码。

If you're looking for a full IDE solution that handles all of this with PyQt automatically, I'm unaware of the existence of one.如果你正在寻找一个完整的 IDE 解决方案,它可以自动处理 PyQt 的所有这些,我不知道存在一个。 I just have a build_helper.py script that processes all of my .ui files and places them in the appropriate place in the python package I'm developing.我只有一个build_helper.py脚本,它处理我所有的 .ui 文件并将它们放在我正在开发的 python 包中的适当位置。 I run the build helper script before running the actual main program to ensure that the generated code is up to date.我在运行实际主程序之前运行构建帮助程序脚本,以确保生成的代码是最新的。

All of my .ui files go into a subfolder ui in the project root.我所有的 .ui 文件都进入项目根目录中的子文件夹ui中。 The script then creates python source and places it into 'myapp/ui/generated'.然后脚本创建 python 源并将其放入“myapp/ui/generated”。

For example:例如:

import os.path
from PyQt4 import uic

generated_ui_output = 'myapp/ui/generated'

def process_ui_files():
    ui_files = (glob.glob('ui/*.ui'),
                glob.glob('ui/Dialogs/*.ui'),
                glob.glob('ui/Widgets/*.ui')))
    for f in ui_files:
        out_filename = (
            os.path.join(
                generated_ui_output,
                os.path.splitext(
                    os.path.basename(f))[0].replace(' ', '')+'.py')
        )
        out_file = open(out_filename, 'w')
        uic.compileUi(f, out_file)
        out_file.close()

if __name__ == '__main__':
    process_ui_files()

I also have a few other functions in there for running pyrcc4 for resource compilation and pylupdate4 and lrelease to generate translations.我还有一些其他函数,用于运行pyrcc4进行资源编译,以及运行pylupdate4lrelease以生成翻译。

looks like You are looking for this : https://build-system.fman.io/qt-designer-download看起来你正在寻找这个: https : //build-system.fman.io/qt-designer-download

sweet and simple: QT designer for mac lighter and simpler than original QT creator .... just for python甜蜜而简单:Mac 的 QT 设计器比原始的 QT 设计器更轻巧、更简单......仅适用于 python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM