Qt Designer for PyQt on OSX 10.6
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'.
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.