Esempio n. 1
0
def main(argv, pkg):
    """
    Start Qt and a session of the application.
    """

    from code_saturne.cs_exec_environment import set_modules, source_rcfile
    set_modules(pkg)
    source_rcfile(pkg)

    images_path = os.path.join(pkg.get_dir('pkgdatadir'), 'images')

    # Test if EOS modules could be imported
    cfg = cs_config.config()
    if cfg.libs['eos'].have == "yes":
        eosprefix = cfg.libs['eos'].prefix
        try:
            from distutils import sysconfig
            eospath = os.path.join(sysconfig.get_python_lib(0, 0, prefix=eosprefix), 'eos')
        except Exception:
            eospath = ''

        if sys.platform.startswith('win'):
            eospath = os.path.join(eosprefix,
                          'lib', 'python' + sys.version[:3], 'site-packages',
                          'eos')

        if eospath:
            if os.path.isdir(eospath) and not eospath in sys.path:
                sys.path.insert(0, eospath)

    case, spl = process_cmd_line(argv)

    app = QApplication(sys.argv)
    app.setOrganizationName(pkg.code_name) # Defines the name of subdirectory under .config
    app.setOrganizationDomain(pkg.url)
    app.setApplicationName("gui") # Defines the name of the configuration file
    #app.setWindowIcon(QIcon(":/icon.png"))
    app.lastWindowClosed.connect(app.quit)

    # Locale detection
    locale = QLocale.system().name()
    translator = QTranslator(app)
    if translator.load("qt_" + locale,
                       QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
        app.installTranslator(translator)

    if spl:
        app.setOverrideCursor(QCursor(Qt.WaitCursor))
        pixmap = QPixmap('%s/splashscreen.png' % images_path)
        splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
        splash.setMask(pixmap.mask()) # this is usefull if the splashscreen is not a regular ractangle...
        splash.show()
        if pkg.name == 'neptune_cfd':
            splash.showMessage("%(name)s %(vers)s starting..." \
                               % {'name': pkg.name, 'vers':pkg.version},
                               Qt.AlignHCenter | Qt.AlignVCenter, Qt.black)
        app.processEvents()
        QTimer.singleShot(1500, splash.hide)

    from code_saturne.Base.MainView import MainView
    mv = MainView(cmd_package = pkg, cmd_case = case)

    try:
        mv.show()
        if spl:
            app.processEvents()
            app.restoreOverrideCursor()
    except:
        print("\n  Unable to display a Qt window.")
        print("  Please check your display environment.\n")
        sys.exit(0)

    sys.exit(app.exec_())
Esempio n. 2
0
        splash.setMask(pixmap.mask(
        ))  # this is useful if the splashscreen is not a regular ractangle...
        splash.show()
        if pkg.name == 'neptune_cfd':
            splash.showMessage("%(name)s %(vers)s starting..." \
                               % {'name': pkg.name, 'vers':pkg.version},
                               Qt.AlignHCenter | Qt.AlignVCenter, Qt.black)
        app.processEvents()
        QTimer.singleShot(1500, splash.hide)

    if os.path.split(case)[1] == "run.cfg":
        from code_saturne.Base.QCouplingEditorView import QCouplingEditor
        mv = QCouplingEditor(cfgfile=case, standalone_mode=True)
    else:
        from code_saturne.Base.MainView import MainView
        mv = MainView(cmd_package=pkg, cmd_case=case)

    try:
        mv.show()
        if spl:
            app.processEvents()
            app.restoreOverrideCursor()
    except:
        print("\n  Unable to display a Qt window.")
        print("  Please check your display environment.\n")
        sys.exit(0)

    sys.exit(app.exec_())


#-------------------------------------------------------------------------------
Esempio n. 3
0
def main(argv, pkg):
    """
    Start Qt and a session of the application.
    """

    from cs_exec_environment import set_modules, source_rcfile
    set_modules(pkg)
    source_rcfile(pkg)

    # Test the package name to know which modules have to be imported
    if pkg.name == 'code_saturne':
        images_path = os.path.join(pkg.get_dir('pkgdatadir'), 'images')
        sys.path.insert(1, os.path.join(pkg.get_dir('pkgpythondir'), 'Base'))
    else:
        images_path = os.path.join(pkg.get_dir('pkgpythondir'), 'core', 'icons')
        sys.path.insert(1, os.path.join(pkg.get_dir('pkgpythondir'), 'core'))
        sys.path.insert(1, pkg.get_dir('cspythondir'))

    # Test if EOS modules could be imported
    cfg = cs_config.config()
    if cfg.libs['eos'].have == "yes":
        eosprefix = cfg.libs['eos'].prefix
        try:
            from distutils import sysconfig
            eospath = os.path.join(sysconfig.get_python_lib(0, 0, prefix=eosprefix), 'eos')
        except Exception:
            eospath = ''

        if sys.platform.startswith('win'):
            eospath = os.path.join(eosprefix,
                          'lib', 'python' + sys.version[:3], 'site-packages',
                          'eos')

        if eospath:
            if os.path.isdir(eospath) and not eospath in sys.path:
                sys.path.insert(0, eospath)

    case, spl = process_cmd_line(argv)

    app = QApplication(argv)
    app.setOrganizationName(pkg.code_name) # Defines the name of subdirectory under .config
    app.setOrganizationDomain(pkg.url)
    app.setApplicationName("gui") # Defines the name of the configuration file
    #app.setWindowIcon(QIcon(":/icon.png"))
    app.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))

    # Locale detection
    locale = QLocale.system().name()
    translator = QTranslator(app)
    if translator.load("qt_" + locale,
                       QLibraryInfo.location(QLibraryInfo.TranslationsPath)):
        app.installTranslator(translator)

    if spl:
        app.setOverrideCursor(QCursor(Qt.WaitCursor))
        pixmap = QPixmap('%s/splashscreen.png' % images_path)
        splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
        splash.setMask(pixmap.mask()) # this is usefull if the splashscreen is not a regular ractangle...
        splash.show()
        if pkg.name == 'neptune_cfd':
            splash.showMessage("%(name)s %(vers)s starting..." \
                               % {'name': pkg.name, 'vers':pkg.version},
                               Qt.AlignHCenter | Qt.AlignVCenter, Qt.black)
        app.processEvents()
        QTimer.singleShot(1500, splash.hide)

    from code_saturne.Base.MainView import MainView
    mv = MainView(cmd_package = pkg, cmd_case = case)

    try:
        mv.show()
        if spl:
            app.processEvents()
            app.restoreOverrideCursor()
    except:
        print("\n  Unable to display a Qt window.")
        print("  Please check your display environment.\n")
        sys.exit(0)

    sys.exit(app.exec_())