Tags

Saturday, July 7, 2012

Qt Designer

Before I begin writing a new UI in PyQt, I like to use Designer to help design my UI and get some ideas down on screen. Designer is a tool that is part of the Qt download package, you can read more about it here.

It's great for putting some widgets and layouts together to visualise how you'd like your UI to look before writing it in Python. Or... you could just use the loadUI() method in Maya to bring it directly into Maya. I don't recommend this though, it's not very optimised and a bit annoying to connect up to custom methods.

Converting a .ui file to .py:
Save your .ui file you've just made in Designer, then load up command window (Windows) or terminal for OSX/Linux. Navigate to the folder where the .ui file is and type:

pyuic4 example.ui > example.py

This converts your .ui to a .py file, which you can now open and pick out what code you'd like to re-write and optimise. Pretty handy!

Check out this page for a slightly dated but still relevant tutorial: http://www.cs.usfca.edu/~afedosov/qttut/