schrodinger.ui.qt.appframework2.application module

Functions for managing the global QApplication instance.

Typical usage:

if __name__ == ‘__main__’:
af2.start_application(MyPanel.panel)

(Note that the start_application function is available from the af2 namespace)

schrodinger.ui.qt.appframework2.application.ApplicationMode

alias of schrodinger.ui.qt.appframework2.application.RunMode

schrodinger.ui.qt.appframework2.application.require_application(func=None, create=False, use_qtcore_app=False)

Use this decorator on functions that require a QApplication to run. When the decorated function is called, this will check whether a QApplication exists. If it does not, a RuntimeError will be raised unless create=True, which will cause a QApplication to be created.

Parameters:
  • func – the function to decorate
  • create (bool) – whether to create a QApplication if one does not exist
  • use_qtcore_app (bool) – Whether to create the application using the QtCore module instead of the QtWidgets module.
schrodinger.ui.qt.appframework2.application.get_application(create=True, use_qtcore_app=False)

Gets the global QApplication instance. By default, creates one if none exists.

Parameters:
  • create (bool) – Whether to create a new application if none exists.
  • use_qtcore_app – Whether to create the application using the QtCore module instead of the QtWidgets module. Has no effect if create is False.
Returns:

the application

Return type:

QApplication or None

schrodinger.ui.qt.appframework2.application.get_app_mode()

Returns the current application mode, which is a member of the ApplicationMode enum.

schrodinger.ui.qt.appframework2.application.in_canvas()

Checks whether we are currently running from within canvas

schrodinger.ui.qt.appframework2.application.start_application(main_callable, use_qtcore_app=False)

Begins the application’s event loop using the exec_ method. The main callable is called via timer from within the event loop. This function is meant to be used when running in standalone scripts as follows:

if __name__ == ‘__main__’:
application.start_application(main)

Using this function to launch standalone scripts/panels more closely mimics the way python is run under Maestro. For exmaple, a panel may be presented with MyPanel.show() without having to call application.exec_().

Parameters:
  • main_callable (callable) – the function/method to be run in the event loop, commonly a module level main function or MyPanelClass.panel
  • use_qtcore_app (bool) – Whether to create the application using the QtCore module instead of the QtWidgets module.
schrodinger.ui.qt.appframework2.application.process_events(flags=None)

Calls processEvents on the main event loop. Requires a QApplication.

Parameters:flags – passed to processEvents. See QApplication.processEvents for documentation
Raises:RuntimeError – if there is no QApplication
schrodinger.ui.qt.appframework2.application.quit_application()

Quits the application.

schrodinger.ui.qt.appframework2.application.deprecated_wait_for_job(job)

This is created for compatibility mode only. Use signal behavior as below.

job_manager = maestro_ui.get_job_manager() job_view_filter = maestro_ui.JobViewFilter( job_manager, False, True, self.viewname, False) job_view_filter.jobStarted.connect(..) job_view_filter.jobsStateChanged.connect(..) job_view_filter.errorOccurred.connect(..) job_view_filter.launchJob(..)