Working with PySide graphic package

The PySide LGPL-licensed open source project ( is a Python wrapper for the Qt cross-platform library ( PySide is used to develop user interfaces.

A special build of the package is included in Cerebro distribution pack.

PySide features

The Cerebro application uses the Qt library as well, so there are some things to mention about PySide usage.

QApplication - there may be only one instance of QApplication class, and it is created by the application itself, so you don’t need to create it while programming with PySide:

def show_window():
    #app = QtGui.QApplication(sys.argv) do not create!!!

    box = QtGui.QMessageBox()
    box.setText('Hello, World!')

To block the main interface use dialogs or their inheritors:

def show_dialog():

    class MyDialog(QtGui.QDialog): # Dialog class

    dialog = MyDialog()
    dialog.exec_() # main application interface remains blocked until the dialog window is closed

Use global objects to create windows that don’t block the main interface:

global_window = None

def show_global_window():
    global global_window

            if global_window == None: # if a window object is not created yet, creating it
                    global_window = QtGui.QLabel()
                    global_window.setText('Displaying the window for the first time')
                    global_window.setText('Displaying the window for the next time')


PySide has an issue - it is impossible to restart Python modules without restarting the whole application. That is, you have to disable the Auto-reload Python modules button and not to use the Python interpreter full restart button, otherwise there is a risk of application crash. The issue is caused by the problems of Python interpreter re-initializing, that we can not resolve. So you have to restart the application each time for the changes to take effect.

Using PyQt

If you are familiar with programming on PyQt (, it won’t be difficult for you to switch to PySide, because they both have almost the same interface. Moreover, if you have a PyQt code, it won’t take you much to port it to PySide to use in Cerebro.

Some minor differences between PySide and PyQt are described here:

If you still intend to stick to PyQt for extending Cerebro functionality, you will need:

  • to have a build of PyQt based on the same version and bitdepth of the Qt library that the application is. Actual Qt version is 4.7.3.
  • to follow the same recommendations on code writing that are effective for PySide.