def testCreateMainApplication(self):
        ma = MainApplication()

        self.assertEqual(ma.size().width(), 600)
        self.assertEqual(ma.size().height(), 400)

        self.assertEqual(ma.pos().x(), 100)
        self.assertEqual(ma.pos().y(), 150)
    def testCreateMainApplication(self):
        ma = MainApplication()

        self.assertEqual(ma.size().width(), 600)
        self.assertEqual(ma.size().height(), 400)
        
        self.assertEqual(ma.pos().x(), 100)
        self.assertEqual(ma.pos().y(), 150)
Пример #3
0
def sans_gui_main(app_args):
    locale.setlocale(locale.LC_ALL, '')

    from PySide2 import QtWidgets

    app = QtWidgets.QApplication(sys.argv)
    logging.basicConfig(level='DEBUG')

    info.set_applications_settings(app)

    old_stdout = sys.stdout
    sys.stdout = ConsumeOutput()
    #     sys.stdout = redirectstdout = ConsumeOutput()
    program_header()
    sys.stdout = old_stdout

    from mapclient.core.mainapplication import MainApplication
    model = MainApplication()
    model.readSettings()

    wm = model.workflowManager()
    pm = model.pluginManager()
    pam = model.package_manager()
    om = model.optionsManager()

    pam.load()
    pm.load()

    _prepare_internal_workflows(om)

    try:
        wm.load(app_args.workflow)
    except:
        logger.error('Not a valid workflow location: "{0}"'.format(
            app_args.workflow))
        sys.exit(INVALID_WORKFLOW_LOCATION_GIVEN)

    wm.registerDoneExecutionForAll(wm.execute)

    if wm.canExecute():
        wm.execute()
    else:
        logger.error('Could not execute workflow.')

    # Possibly don't need to run app.exec_()
    return app.quit()
Пример #4
0
def non_gui_main(app_args):
    locale.setlocale(locale.LC_ALL, '')

    #     from optparse import OptionParser
    from PySide import QtGui
    #     app = QtCore.QCoreApplication(sys.argv)
    app = QtGui.QApplication(sys.argv)
    logging.basicConfig(level='DEBUG')

    info.setApplicationsSettings(app)

    old_stdout = sys.stdout
    sys.stdout = ConsumeOutput()
    #     sys.stdout = redirectstdout = ConsumeOutput()
    programme_header()
    sys.stdout = old_stdout

    from mapclient.core.mainapplication import MainApplication
    model = MainApplication()
    model.readSettings()

    wm = model.workflowManager()
    pm = model.pluginManager()

    pm.load()
    try:
        wm.load(app_args.workflow)
    except:
        logger.error('Not a valid workflow location: {0}'.format(
            app_args.workflow))
        sys.exit(-1)

    wm.registerDoneExecutionForAll(wm.execute)

    if wm.canExecute():
        wm.execute()
    else:
        logger.error('Could not execute workflow.')

    # Possibly don't need to run app.exec_()
    return app.quit()
 def testWorkflowManagerAPI(self):
     ma = MainApplication()
     wm = ma.workflowManager()
     self.assertTrue(wm.setPreviousLocation('here') == None)
     self.assertEqual(wm.previousLocation(), 'here')
Пример #6
0
def windows_main(app_args):
    """
    Initialise common settings and check the operating environment before starting the application.
    """
    if sys.platform == 'win32':
        my_app_id = 'MusculoSkeletal.MAPClient'  # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(
            my_app_id)

    # import the locale, and set the locale. This is used for
    # locale-aware number to string formatting
    locale.setlocale(locale.LC_ALL, '')

    from PySide2 import QtWidgets
    from mapclient.splashscreen import SplashScreen

    app = QtWidgets.QApplication(sys.argv)

    splash = SplashScreen()
    splash.show()
    splash.showMessage("Loading settings ...", 5)
    info.set_applications_settings(app)

    log_path = get_log_location()
    initialise_logger(log_path)
    program_header()

    logger.info('Setting toolbox settings for matplotlib and enthought to: qt')

    splash.showMessage('Loading opencmiss.zinc ...', 10)
    try:
        from opencmiss.zinc.context import Context
        Context("MAP")
        logger.info('OpenCMISS-Zinc is available.')
    except ImportError:
        logger.warning(' *** OpenCMISS-Zinc is not available ***')

    splash.showMessage('Creating application ...', 20)
    from mapclient.core.mainapplication import MainApplication
    model = MainApplication()

    splash.showMessage('Creating main window ...', 30)
    from mapclient.view.mainwindow import MainWindow
    window = MainWindow(model)

    # Run Checks
    if not window.check_application_setup():
        window.setup_application()

        splash.showMessage('Check application setup ...', 40)
        if not window.check_application_setup():
            window.show_options_dialog(current_tab=1)

    splash.showMessage('Loading packages ...', 50)
    window.load_packages()
    splash.showMessage('Loading plugins ...', 60)
    window.load_plugins()

    splash.showMessage('Loading internal workflow ...', 70)
    om = model.optionsManager()
    _prepare_internal_workflows(om)
    if om.getOption(AUTOLOAD_PREVIOUS_WORKFLOW):
        _load_previous_workflow(app_args, om)

    wm = model.workflowManager()
    if app_args.workflow and not wm.is_restricted(app_args.workflow):
        splash.showMessage('Opening workflow ...', 80)
        logger.info(f"Opening workflow: {app_args.workflow}")
        window.open_workflow(app_args.workflow)
    elif app_args.workflow:
        logger.info(
            f"Not opening workflow '{app_args.workflow}', at least some required plugins are already in use."
        )

    if app_args.execute:
        splash.showMessage('Executing workflow ...', 90)
        if wm.canExecute():
            window.execute()
        else:
            logger.error('Could not execute workflow.')

    window.show()
    splash.showMessage('Ready ...', 100)
    splash.finish(window)
    return app.exec_()
Пример #7
0
def windows_main(app_args):
    """
    Initialise common settings and check the operating environment before starting the application.
    """
    if sys.platform == 'win32':
        myappid = 'MusculoSkeletal.MAPClient'  # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

    # import the locale, and set the locale. This is used for
    # locale-aware number to string formatting
    locale.setlocale(locale.LC_ALL, '')

    from PySide import QtGui
    app = QtGui.QApplication(sys.argv)

    # Set the default organisation name and application name used to store application settings
    info.setApplicationsSettings(app)

    log_path = getLogLocation()
    initialiseLogger(log_path)
    programme_header()

    logger.info(
        'Setting toolbox settings for matplotlib and enthought to: qt4')

    try:
        from opencmiss.zinc.context import Context
        Context("MAP")
        logger.info('OpenCMISS-Zinc is available.')
    except ImportError:
        logger.warning('OpenCMISS-Zinc is not available.')

    try:
        from opencmiss.iron import iron
        logger.info('OpenCMISS-Iron is available.')
    except ImportError:
        logger.warn('OpenCMISS-Iron is not available.')

    from mapclient.core.mainapplication import MainApplication
    model = MainApplication()

    from mapclient.view.mainwindow import MainWindow
    window = MainWindow(model)
    window.show()

    # Run Checks
    if not window.checkApplicationSetup():
        window.setupApplication()

        if not window.checkApplicationSetup():
            window.showOptionsDialog(current_tab=1)

    window.loadPlugins()

    if app_args.workflow:
        window.openWorkflow(app_args.workflow)

    if app_args.execute:
        wm = model.workflowManager()
        if wm.canExecute():
            window.execute()
        else:
            logger.error('Could not execute workflow.')

    return app.exec_()
 def testWorkflowManagerAPI(self):
     ma = MainApplication()
     wm = ma.workflowManager()
     self.assertTrue(wm.setPreviousLocation('here') == None)
     self.assertEqual(wm.previousLocation(), 'here')