Example #1
0
def loadUiType(uifile, from_imports=False, resource_suffix='_rc'):
    """loadUiType.py(uifile, from_imports=False) -> (form class, base class)

    Load a Qt Designer .ui file and return the generated form class and the Qt
    base class.

    uifile is a file name or file-like object containing the .ui file.
    from_imports is optionally set to use import statements that are relative
    to '.'.
    resource_suffix is the suffix appended to the basename of any resource file
    specified in the .ui file to create the name of the Python module generated
    from the resource file by pyrcc4.  The default is '_rc', i.e. if the .ui
    file specified a resource file called foo.qrc then the corresponding Python
    module is foo_rc.
    """

    import sys

    from PyQt4 import QtGui

    if sys.hexversion >= 0x03000000:
        from PyQt4.uic.port_v3.string_io import StringIO
    else:
        from PyQt4.uic.port_v2.string_io import StringIO

    code_string = StringIO()
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports, resource_suffix)

    ui_globals = {}
    exec(code_string.getvalue(), ui_globals)

    return (ui_globals[winfo["uiclass"]], getattr(QtGui, winfo["baseclass"]))
Example #2
0
def loadUiType(uifile, from_imports=False, resource_suffix='_rc'):
    """loadUiType(uifile, from_imports=False) -> (form class, base class)

    Load a Qt Designer .ui file and return the generated form class and the Qt
    base class.

    uifile is a file name or file-like object containing the .ui file.
    from_imports is optionally set to use import statements that are relative
    to '.'.
    resource_suffix is the suffix appended to the basename of any resource file
    specified in the .ui file to create the name of the Python module generated
    from the resource file by pyrcc4.  The default is '_rc', i.e. if the .ui
    file specified a resource file called foo.qrc then the corresponding Python
    module is foo_rc.
    """

    import sys

    from PyQt4 import QtGui

    if sys.hexversion >= 0x03000000:
        from PyQt4.uic.port_v3.string_io import StringIO
    else:
        from PyQt4.uic.port_v2.string_io import StringIO

    code_string = StringIO()
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports, resource_suffix)

    ui_globals = {}
    exec(code_string.getvalue(), ui_globals)

    return (ui_globals[winfo["uiclass"]], getattr(QtGui, winfo["baseclass"]))
Example #3
0
def loadUiType(uifile, from_imports=False):
    """loadUiType(uifile) -> (form class, base class)

    Load a Qt Designer .ui file and return the generated form class and the Qt
    base class.

    uifile is a file name or file-like object containing the .ui file.
    from_imports is optionally set to use import statements that are relative
    to '.'.
    """

    import sys

    from PyQt4 import QtGui

    if sys.hexversion >= 0x03000000:
        from PyQt4.uic.port_v3.string_io import StringIO
    else:
        from PyQt4.uic.port_v2.string_io import StringIO

    code_string = StringIO()
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports)

    ui_globals = {}
    exec(code_string.getvalue(), ui_globals)

    return (ui_globals[winfo["uiclass"]], getattr(QtGui, winfo["baseclass"]))
Example #4
0
def loadUiType(uifile, from_imports=False):
    """loadUiType(uifile, from_imports=False) -> (form class, base class)

    Load a Qt Designer .ui file and return the generated form class and the Qt
    base class.

    uifile is a file name or file-like object containing the .ui file.
    from_imports is optionally set to use import statements that are relative
    to '.'.
    """

    import sys

    from PyQt4 import QtGui

    if sys.hexversion >= 0x03000000:
        from PyQt4.uic.port_v3.string_io import StringIO
    else:
        from PyQt4.uic.port_v2.string_io import StringIO

    code_string = StringIO()
    winfo = compiler.UICompiler().compileUi(uifile, code_string, from_imports)

    ui_globals = {}
    exec(code_string.getvalue(), ui_globals)

    return (ui_globals[winfo["uiclass"]], getattr(QtGui, winfo["baseclass"]))