Oct 122012

PyQt4 UI Development for Maya

Just released my 3rd python-based online training video through cmiVFX.com


This tutorial is about learning PyQt4 python bindings for the Qt Framework, and how to introduce new UI elements to Maya as a platform.
We discuss what comprises a “Framework” and a “GUI Framework”, and how Qt and PyQt4 work together.


Getting Started With PyQt4

There are multiple ways of getting a working installation of PyQt4, both for the general system and for Maya. We look into these approaches to get your system up and running to begin working with PyQt4!
We also talk about what is included, such as command line tools and applications, tips on how to test and learn the code, and how to structure a project.


PyQt4 Fundamentals

Lets get crackin’ and learn the basics!
• What is a QObject? What is a QWidget? Common PyQt4 classes are explained in detail
• Working with the Qt Designer application, to build a UI visually
• Layouts: Making widgets resize elegantly and stay organized in your design
• Coordinate space: How do widgets transform in your 2D screen space?
• QApplication and the Qt Event Loop: The engine that runs your UI
• Events, Signals, and Slots: How components communicate changes and how the application can respond to changes to make it dynamic


General Examples

With an understanding of the framework components, we can begin working with fully functional stand-alone examples.
• Common PyQt4 app template
• Subclassing Widgets: Creating custom functionality to the existing classes provided by PyQt4
• Dialogs: Raising dialog windows above existing windows, Modal vs Non-modal, and creating forms. We look at different ways to validate the data provided by the user, to these dialog forms.


PyQt4 And Maya Introduction

Finally, some Maya action! Maya has a slightly different approach to using PyQt4…
• How does the QApplication and event loop work?
• Common Maya PyQt4 app template
• Looking at the Maya API’s MQtUtil class
• The sip module: Helping us translate between Maya’s Qt and our own PyQt4 code


Replicating Maya’s UI Components

What better way to see examples of creating UI for Maya than to replicate some existing functionality? This gives us the opportunity expand with custom functionality
In this chapter we will take two different UI components in Maya, and do a basic custom version of our own, and show to how link them up to Maya’s own callbacks.
Some Features Of This Chapter Include
• The QTableWidget
• Model / View separation with QTreeView
• Docking windows into the Maya interface
• Mixing together PyQt4, the Maya API, Maya commands, and callbacks
• Sorting model data



A button can be a button, and a slider might look alright in its stock form, but sometimes we want to customize the look of our widgets. This chapter introduces multiple ways of achieving custom looks to our components
• Stylin’ Stylesheets: Use CSS-like syntax for applying style sheets to widgets
• Painting By … Paint events: For even more control, we can tell a widget exactly how to draw itself on the screen. We will look at two different examples of how to use custom painting.

Previous cmiVFX tutorials:

Nov 092011

This is a follow up post to my previous one on Installing PyQt4 for Maya 2011

Recently while putting together my next video tutorial for Python for Maya, I came to a section where I wanted to demo PyQt4 in Maya2012. But I was concerned that viewers would have to go through the complicated steps of building PyQt4. I noticed that other people have made available precompiled PyQt installers for windows (here) but I could not find any for OSX or linux. So I decided to put together a build.

I created a new project on github called MyQt4

Its a Makefile for completely downloading and building PyQt4 for maya, and generating a .pkg installer. Hopefully someone can contribute improvements since I dont have a ton of experience writing makefiles, and also that someone might create a linux version.

Here is a link to the latest pkg build:

Snow Leopard: 


Mountain Lion:

Here are builds other people have made:

May 112010


AtomSplitter (chanToFbx) has been updated to v1.2, available through cmivfx.com

AtomSplitter 1.2 – cmiVFX.com


  • Camera rotation order set to ZXY, which is the Nuke camera default
  • Fixed a bug where the FocalLength value was not being keyframed properly
  • Added a scene scale field, for adjusting the translation values globally.

If you haven’t visited cmiVFX.com before, PLEASE check them out. Chris Maynard does an amazing job rounding up top talent in the industry to create these outstanding visual fx tutorials. The information is always cutting edge.

See the original post.

Mar 182010

“App’ing up” PyQt… ugh.

One of biggest problems with PyQt is distributing it in a stand-alone package. Even worse… wanting to make your Qt plugins still function (Phonon, jpeg, etc). At work I constantly had this battle, along with my co-worker Tory. She actually has a long-standing issue with this, and had to resort to workarounds or half fixes. Here is Tory’s original post regarding the issue .

I would see an error similar to this when trying to package up and run an app using the Phonon module.

WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded


macdeployqt myAppName.app

does add things like the jpeg plugin, but never seemed to fix the Phonon issue. I finally decided to randomly look online for a solution, again, last week. What I found was a partial solution, followed by me trying one more thing and bam…it worked! Video playback from my .app standalone package.

Here is what I did …
(btw you might have to modify the location of the plugin, since I happen to be using OSX)

  1. In your setup.py file, which is used for py2app, py2exe, or similar… add this to the DATA_FILES list, so that it looks as such:
    DATA_FILES = [('phonon_backend',
    ['/Developer/Applications/Qt/plugins/phonon_backend/libphonon_qt7.dylib'] )]

    This will put the phonon backend plugin into the RESOURCES folder in the app.

  2. Package up your application via py2app / py2exe / etc.
  3. If you are on OSX, use macdeployqt on the app:
    >>> macdeployqt myApp.app
  4. Go into the app that was created (show package contents if you are on a mac), and move the phonon_backend directory FROM the Resources directory TO the PlugIns directory (which should be at the same level as Resources).

That should be it!