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).
At this point, I have successfully installed SIP, Qt4, and PyQt4.
The PyQt binary installers (for Windows) include a version of Qt Designer that works with PyQt. On OSX, there is no binary installer, just source. So no Qt Designer.
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++.
Is there a way to make Qt Creator work with PyQt? Or is there another GUI designer for PyQt that works on a Mac?
If you've installed Qt4, then you have Qt Designer. If you used the installer from qt.nokia.com, it should be in /Developer/Applications/Qt.
Qt Designer itself works just fine with PyQt. Qt designer just spits out XML describing the UI structure. If you were using standard Qt with C++, you would have to run the
uic tool to generate C++ from the .ui files. Likewise, with PyQt4, you must run
pyuic4 on the generated .ui file to create python source from it.
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. 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. 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. The script then creates python source and places it into 'myapp/ui/generated'.
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)).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
lrelease to generate translations.