def main() -> int: command_line_args = parse_commandline() exit_code_str = command_line_args.exit_code exit_code = int(exit_code_str) if mantid.config['usagereports.enabled'] != '1': return exit_code # On Windows/macOS the plugin locations need to be known before starting # QApplication if command_line_args.qtdir is not None: QCoreApplication.addLibraryPath(command_line_args.qtdir) # Qt resources must be imported before QApplication starts importlib.import_module( f'mantidqt.dialogs.errorreports.resources_qt{QT_VERSION[0]}') from qtpy.QtWidgets import QApplication app = QApplication(sys.argv) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, exit_code_str, command_line_args.application) presenter.show_view() app.exec_() return exit_code
def main(argv: Sequence[str] = None) -> int: argv = argv if argv is not None else sys.argv command_line_args = parse_commandline(argv) exit_code_str = command_line_args.exit_code exit_code = int(exit_code_str) if mantid.config['usagereports.enabled'] != '1': return exit_code # On Windows/macOS the plugin locations need to be known before starting # QApplication if command_line_args.qtdir is not None: QCoreApplication.addLibraryPath(command_line_args.qtdir) # Qt resources must be imported before QApplication starts importlib.import_module(f'mantidqt.dialogs.errorreports.resources_qt{QT_VERSION[0]}') if sys.platform == 'darwin': qtutils.force_layer_backing_BigSur() from qtpy.QtWidgets import QApplication app = QApplication(argv) # The strings APPNAME, ORG_DOMAIN, ORGANIZATION are duplicated from workbench.config app.setOrganizationName(command_line_args.org_name) app.setOrganizationDomain(command_line_args.org_domain) app.setApplicationName(command_line_args.application) QSettings.setDefaultFormat(QSettings.IniFormat) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, exit_code_str, command_line_args.application) presenter.show_view() app.exec_() return exit_code
def setup_library_paths_win(): """Adds the build-time configured directory to the Qt library path. The buildsystem generates the path at build time. A %V marker can be used that will be replaced by the major version of Qt at runtime. """ import os.path as osp import sys from qtpy import QT_VERSION from qtpy.QtCore import QCoreApplication conda_prefix = os.environ.get("CONDA_PREFIX", "") if conda_prefix != "": conda_qt_plugins = osp.join(conda_prefix, "Library", "plugins") QCoreApplication.addLibraryPath(conda_qt_plugins) return # package build pkg_qt_plugins = osp.dirname(sys.executable) + f'\\..\\plugins\\qt{QT_VERSION[0]}' if osp.isdir(pkg_qt_plugins): QCoreApplication.addLibraryPath(pkg_qt_plugins) return # development build dev_qt_plugins = osp.dirname(sys.executable) + f'\\..\\qt{QT_VERSION[0]}\\plugins' if osp.isdir(dev_qt_plugins): QCoreApplication.addLibraryPath(dev_qt_plugins) return
def _init_pyqt(self, exp): global app, font_database # Add the Qt plugin folders to the library path, if they exists. Where # these folders are depends on the version of Qt4, but these are two # possible locations. qt_plugin_path = os.path.join(os.path.dirname(sys.executable), 'Library', 'plugins') if os.path.isdir(qt_plugin_path): QCoreApplication.addLibraryPath( safe_decode(qt_plugin_path, enc=misc.filesystem_encoding())) qt_plugin_path = os.path.join(os.path.dirname(sys.executable), 'Library', 'lib', 'qt4', 'plugins') if os.path.isdir(qt_plugin_path): QCoreApplication.addLibraryPath( safe_decode(qt_plugin_path, enc=misc.filesystem_encoding())) # If no instance of QApplication exists, a segmentation fault seems to always # occur. So we create one. if QCoreApplication.instance() is None: app = QApplication([]) # Register the fonts bundled with OpenSesame if font_database is None: font_database = QFontDatabase() for font in FONTS: try: path = exp.resource(font + u'.ttf') except: warnings.warn(u'Font %s not found' % font) continue font_id = font_database.addApplicationFont(path) if font_id < 0: warnings.warn(u'Failed to load font %s' % font) continue font_families = font_database.applicationFontFamilies(font_id) if not font_families: warnings.warn(u'Font %s contains no families' % font) continue font_substitutions.append((font_families[0], font))
sys.path.insert(0, command_line_args.directory) from qtpy import QtGui, QtWidgets # noqa import mantid # noqa try: from ErrorReporter import resources_qt5 # noqa except ImportError: from ErrorReporter import resources_qt4 # noqa from ErrorReporter.error_report_presenter import ErrorReporterPresenter # noqa from ErrorReporter.errorreport import CrashReportPage # noqa # Set path to look for package qt libraries if command_line_args.qtdir is not None: from qtpy.QtCore import QCoreApplication QCoreApplication.addLibraryPath(command_line_args.qtdir) def main(): if mantid.config['usagereports.enabled'] != '1': return int(command_line_args.exit_code) app = QtWidgets.QApplication(sys.argv) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, command_line_args.exit_code) presenter.show_view() app.exec_() return int(command_line_args.exit_code) if __name__ == '__main__': # if we're running file directly and not importing it sys.exit(main()) # run the main function
from ErrorReporter import resources_qt5 # noqa elif qtpy.PYQT4: from ErrorReporter import resources_qt4 # noqa else: raise RuntimeError("Unknown QT version: {}".format(qtpy.QT_VERSION)) from qtpy import QtWidgets # noqa from ErrorReporter.error_report_presenter import ErrorReporterPresenter # noqa from ErrorReporter.errorreport import CrashReportPage # noqa # Set path to look for package qt libraries if command_line_args.qtdir is not None: from qtpy.QtCore import QCoreApplication QCoreApplication.addLibraryPath(command_line_args.qtdir) def main(): if mantid.config['usagereports.enabled'] != '1': return int(command_line_args.exit_code) app = QtWidgets.QApplication(sys.argv) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, command_line_args.exit_code, command_line_args.application) presenter.show_view() app.exec_() return int(command_line_args.exit_code) if __name__ == '__main__': # if we're running file directly and not importing it sys.exit(main()) # run the main function