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()
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_()