def qapplication(): """Either return a reference to an existing application instance or create a new one :return: A reference to the QApplication object """ app = QApplication.instance() if app is None: # attributes that must be set before creating QApplication QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) argv = sys.argv[:] argv[0] = APPNAME # replace application name # Workaround a segfault importing readline with PyQt5 # This is because PyQt5 messes up pystate (internal) modules_by_index # so PyState_FindModule will return null instead of the module address. # Readline (so far) is the only module that falls over during init as it blindly uses FindModules result # The workaround mentioned in https://groups.google.com/forum/#!topic/leo-editor/ghiIN7irzY0 if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin": importlib.import_module("readline") app = QApplication(argv) app.setOrganizationName(ORGANIZATION) app.setOrganizationDomain(ORG_DOMAIN) app.setApplicationName(APPNAME) app.setApplicationVersion(mantid_version_str()) # Spin up the usage service and set the name for the usage reporting # The report is sent when the FrameworkManager kicks up UsageService.setApplicationName(APPNAME) app.setAttribute(Qt.AA_UseHighDpiPixmaps) if hasattr(Qt, 'AA_DisableWindowContextHelpButton'): app.setAttribute(Qt.AA_DisableWindowContextHelpButton) return app
def qapplication(): """Either return a reference to an existing application instance or create a new one :return: A reference to the QApplication object """ app = QApplication.instance() if app is None: QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) argv = sys.argv[:] argv[0] = APPNAME # replace application name # Workaround a segfault with the IPython console when using Python 3.5 + PyQt 5 # Without this using this fix the above combination causes a segfault when the IPython # console is started # The workaround mentioned in https://groups.google.com/forum/#!topic/leo-editor/ghiIN7irzY0 # is to ensure readline is imported before the QApplication object is created if sys.version_info[0] == 3 and sys.version_info[1] == 5: importlib.import_module("readline") app = QApplication(argv) app.setOrganizationName(ORGANIZATION) app.setOrganizationDomain(ORG_DOMAIN) app.setApplicationName(APPNAME) app.setApplicationVersion(mantid_version_str()) # Spin up the usage service and set the name for the usage reporting # The report is sent when the FrameworkManager kicks up UsageService.setApplicationName(APPNAME) if is_required_version(required_version='5.10.0', version=qVersion()): app.setAttribute(Qt.AA_DisableWindowContextHelpButton) return app
def qapplication(): """Either return a reference to an existing application instance or create a new one :return: A reference to the QApplication object """ app = QApplication.instance() if app is None: QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts) argv = sys.argv[:] argv[0] = APPNAME # replace application name # Workaround a segfault with the IPython console when using Python 3.5 + PyQt 5 # Without this using this fix the above combination causes a segfault when the IPython # console is started # The workaround mentioned in https://groups.google.com/forum/#!topic/leo-editor/ghiIN7irzY0 # is to ensure readline is imported before the QApplication object is created if sys.version_info[0] == 3 and sys.version_info[1] == 5: importlib.import_module("readline") app = QApplication(argv) app.setOrganizationName(ORGANIZATION) app.setOrganizationDomain(ORG_DOMAIN) app.setApplicationName(APPNAME) app.setApplicationVersion(mantid_version_str()) # Spin up the usage service and set the name for the usage reporting # The report is sent when the FrameworkManager kicks up UsageService.setApplicationName(APPNAME) return app