def get_qapp ( ) : global app app = QtGui . QApplication . instance ( ) if app is None : app = QtGui . QApplication ( [ ] , QtGui . QApplication . GuiClient ) return app
python must construct a qapplication before qwidget
Return an instance of QApplication . Creates one if neccessary .
def get_qapp():
    """Return an instance of QApplication. Creates one if neccessary.

    :returns: a QApplication instance
    :rtype: QApplication
    :raises: None
    """
    global app
    app = QtGui.QApplication.instance()
    if app is None:
        app = QtGui.QApplication([], QtGui.QApplication.GuiClient)
    return app