Book Image

Practical Maya Programming with Python

By : Robert Galanakis
Book Image

Practical Maya Programming with Python

By: Robert Galanakis

Overview of this book

Table of Contents (17 chapters)
Practical Maya Programming with Python
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating the hierarchy converter GUI


In this section we'll create a PySide user interface for the character creator/hierarchy converter we worked on in Chapter 2, Writing Composable Code. The GUI will respond to the user changing selection, and when the user interacts with the GUI, it will update the Maya scene. This project will teach us the fundamental concepts that allow the decoupling of Maya and PySide components. This decoupling allows an ever-more-complex set of interactions while still keeping the code maintainable.

Creating the window

Our GUI will be a Python script like any other. Let's make a file hierarchyconvertergui.py in our development root C:\mayapybook\pylib. Open it up in your IDE and write:

from qtshim import QtGui, QtCore, Signal

This will import the two main PySide modules into your file, allowing you to use GUI classes (through QtGui) and core library classes (through QtCore), as well as the Signal class. Most of the time you will only use QtGui classes, but in this example...