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
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 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 run(args): """Main entrypoint function Args: args (list): command line arguments to be passed to the application Returns: int: return code to report back to the shell with """ configure_logging() # HACK: this next line was needed to silence an odd warning message generated by Qt QApplication.setAttribute(Qt.AA_ShareOpenGLContexts) # Configure our application app = QApplication(args) app.setOrganizationName("The Friendly Coder") app.setOrganizationDomain("https://github.com/TheFriendlyCoder") app.setApplicationName("FriendlyPics2") app.setApplicationVersion(__version__) # Configure our main window window = MainWindow() window.show() # Attach the Python logging system to the GUI log_handler = GuiLogger(window.findChild(QPlainTextEdit, "debug_log")) logging.getLogger().addHandler(log_handler) # Run our app return app.exec_()
def main(): app = QApplication(sys.argv) QApplication.setOrganizationName("pyCart3d") QApplication.setOrganizationDomain(pyNastran.__website__) QApplication.setApplicationName("pyCart3d") QApplication.setApplicationVersion(pyNastran.__version__) inputs = get_inputs() window = MainWindow(inputs) sys.exit(app.exec_())
def main(main_file, arguments): signal.signal(signal.SIGINT, lambda *args: LiveCodingGui.shutdown()) app = QApplication(sys.argv) app.setOrganizationName('machinekoder.com') app.setOrganizationDomain('machinekoder.com') app.setApplicationName('Python Qt Live Coding') app.setWindowIcon(QIcon(os.path.join(MODULE_PATH, 'icon.png'))) _gui = LiveCodingGui(arguments, main_file) # noqa: F841 sys.exit(app.exec_())
def start(live=False): os.environ['QML_DISABLE_DISTANCEFIELD'] = '1' app = QApplication(sys.argv) app.setApplicationName("APE Main GUI") app.setOrganizationName("UES") app.setOrganizationDomain("www.ues.com") gui = MainGui(live=live) signal.signal(signal.SIGINT, lambda *args: gui.shutdown()) sys.exit(app.exec_())
def main(): if sys.platform == 'win32': import ctypes myappid = 'pynastran.pynastrangui.%s' % (pyNastran.__version__ ) # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) app = QApplication(sys.argv) QApplication.setOrganizationName('pyNastran') QApplication.setOrganizationDomain(pyNastran.__website__) QApplication.setApplicationName('pyNastran') QApplication.setApplicationVersion(pyNastran.__version__) w = MainWindow2() app.exec_()
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 app = QApplication(argv) app.setOrganizationName(ORGANIZATION) app.setOrganizationDomain(ORG_DOMAIN) app.setApplicationName(APPNAME) # not calling app.setApplicationVersion(mantid.kernel.version_str()) # because it needs to happen after logging is monkey-patched in return app
def cmd_line(): """the setup.py entry point for ``pyNastranGUI``""" # this fixes the icon shown in the windows taskbar to be the custom one (not the python one) if sys.platform == 'win32': myappid = 'pynastran.pynastrangui.%s' % (gui_utils.__version__ ) # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) from qtpy.QtWidgets import QApplication app = QApplication(sys.argv) QApplication.setOrganizationName("gui_utils") QApplication.setOrganizationDomain(gui_utils.__website__) QApplication.setApplicationName("gui_utils") QApplication.setApplicationVersion(gui_utils.__version__) inputs = get_inputs() #inputs['app'] = app MainWindow(inputs) app.exec_()
settings.beginGroup('MainWindow') self.resize(settings.value('size', QSize(400, 400))) self.move(settings.value('pos', QPoint(200, 200))) self.container.readSettings(settings) settings.endGroup() def writeSettings(self, settings): """ Save the applications's settings persistently. """ settings.beginGroup('MainWindow') settings.setValue('size', self.size()) settings.setValue('pos', self.pos()) self.container.writeSettings(settings) settings.endGroup() if __name__ == '__main__': # Set up some application basics for saving settings QApplication.setOrganizationName('BNL') QApplication.setOrganizationDomain('bnl.gov') QApplication.setApplicationName('QCamera') # Create the Qt Application app = QApplication(sys.argv) # Create and show the form form = Form() form.show() # Run the main Qt loop sys.exit(app.exec_())
def cmd_line(): """the setup.py entry point for ``pyNastranGUI``""" # this fixes the icon shown in the windows taskbar to be the custom one (not the python one) if sys.platform == 'win32': myappid = 'pynastran.pynastrangui.%s' % (pyNastran.__version__ ) # arbitrary string ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) from qtpy.QtWidgets import QApplication app = QApplication(sys.argv) if 0: # pragma: no cover try: import qtmodern.styles except ImportError: pass else: qtmodern.styles.dark(app) #app.setStyle('Fusion') #app.setStyle('WindowsXP') #if 0: #import qtpy.QtGui as QtGui #import qtpy.QtCore as QtCore #palette = QtGui.QPalette() #palette.setColor(QtGui.QPalette.Window, QtGui.QColor(53,53,53)) #palette.setColor(QtGui.QPalette.WindowText, QtCore.Qt.white) #palette.setColor(QtGui.QPalette.Base, QtGui.QColor(15,15,15)) #palette.setColor(QtGui.QPalette.AlternateBase, QtGui.QColor(53,53,53)) #palette.setColor(QtGui.QPalette.ToolTipBase, QtCore.Qt.white) #palette.setColor(QtGui.QPalette.ToolTipText, QtCore.Qt.white) #palette.setColor(QtGui.QPalette.Text, QtCore.Qt.white) #palette.setColor(QtGui.QPalette.Button, QtGui.QColor(53,53,53)) #palette.setColor(QtGui.QPalette.ButtonText, QtCore.Qt.white) #palette.setColor(QtGui.QPalette.BrightText, QtCore.Qt.red) #palette.setColor(QtGui.QPalette.Highlight, QtGui.QColor(142,45,197).lighter()) #palette.setColor(QtGui.QPalette.HighlightedText, QtCore.Qt.black) #app.setPalette(palette) #if 1: stylesheet = get_stylesheet() if stylesheet: app.setStyleSheet(stylesheet) if 0: # pragma: no cover import qtpy.QtGui as QtGui #import qtpy.QtCore as QtCore from qtpy.QtGui import QPalette, QColor dark_palette = QtGui.QPalette() dark_palette.setColor(QPalette.WindowText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Button, QColor(53, 53, 53)) dark_palette.setColor(QPalette.Light, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Midlight, QColor(90, 90, 90)) dark_palette.setColor(QPalette.Dark, QColor(35, 35, 35)) dark_palette.setColor(QPalette.Text, QColor(180, 180, 180)) dark_palette.setColor(QPalette.BrightText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.ButtonText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Base, QColor(42, 42, 42)) dark_palette.setColor(QPalette.Window, QColor(53, 53, 53)) dark_palette.setColor(QPalette.Shadow, QColor(20, 20, 20)) dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218)) dark_palette.setColor(QPalette.HighlightedText, QColor(180, 180, 180)) dark_palette.setColor(QPalette.Link, QColor(56, 252, 196)) dark_palette.setColor(QPalette.AlternateBase, QColor(66, 66, 66)) dark_palette.setColor(QPalette.ToolTipBase, QColor(53, 53, 53)) dark_palette.setColor(QPalette.ToolTipText, QColor(180, 180, 180)) # disabled dark_palette.setColor(QPalette.Disabled, QPalette.WindowText, QColor(127, 127, 127)) dark_palette.setColor(QPalette.Disabled, QPalette.Text, QColor(127, 127, 127)) dark_palette.setColor(QPalette.Disabled, QPalette.ButtonText, QColor(127, 127, 127)) dark_palette.setColor(QPalette.Disabled, QPalette.Highlight, QColor(80, 80, 80)) dark_palette.setColor(QPalette.Disabled, QPalette.HighlightedText, QColor(127, 127, 127)) app.setPalette(dark_palette) QApplication.setOrganizationName("pyNastran") QApplication.setOrganizationDomain(pyNastran.__website__) QApplication.setApplicationName("pyNastran") QApplication.setApplicationVersion(pyNastran.__version__) inputs = get_inputs(print_inputs=False) #inputs['app'] = app MainWindow(inputs) app.exec_()
def selectedRowChanged(self, index1, index2): row = index1.row() sweep = self.sweepCollection[row] tStart = sweep.time tStop = sweep.time + 10 self.hkDock.highlightTimeSpan(tStart, tStop) # def showSweeps(self, N): # n = len(sweepCollection) # nStep = int(n / N) # for i in range(0, n, nStep): # pass # #self.togglePlot(i, True) if __name__ == '__main__': from qtpy.QtWidgets import QApplication path = 'ExampleData/' fileName = path + 'TES2_IV_20180117_090049.h5' fileName = path + 'TES2_SIV_RampT_20180110_180826.h5' fileName = 'D:/Users/Runs/G5C/IV/TES2_IV_20180403_091910.h5' app = QApplication([]) app.setApplicationName('IvSweepAnalyzer') app.setOrganizationName('WiscXrayAstro') app.setOrganizationDomain('wisp.physics.wisc.edu') mw = MainWindow() mw.loadSweepFile(fileName) mw.show() app.exec_()
def __init__(self, sys_argv): super().__init__() self.__m_vtkFboItem = None #sys_argv += ['--style', 'Material'] #! MUST HAVE #sys_argv += ['--style', 'Fusion'] #! MUST HAVE sys_argv += ['--style', 'Windows'] #! MUST HAVE QApplication.setAttribute(Qt.AA_UseDesktopOpenGL) QtGui.QSurfaceFormat.setDefaultFormat( defaultFormat(False)) # from vtk 8.2.0 app = QApplication(sys_argv) app.setApplicationName("QtQuickVTK") app.setWindowIcon(QIcon(":/resources/bq.ico")) app.setOrganizationName("Sexy Soft") app.setOrganizationDomain("www.sexysoft.com") engine = QQmlApplicationEngine() app.setApplicationName('QtVTK-Py') # Register QML Types qmlRegisterType(FboItem, 'QtVTK', 1, 0, 'VtkFboItem') # Expose/Bind Python classes (QObject) to QML ctxt = engine.rootContext() # returns QQmlContext ctxt.setContextProperty('canvasHandler', self) self.dataProvider = ChartDataProvider() ctxt.setContextProperty('chartDataProvider', self.dataProvider) # Load main QML file engine.load(QUrl.fromLocalFile('resources/main.qml')) # Get reference to the QVTKFramebufferObjectItem in QML rootObject = engine.rootObjects()[0] # returns QObject self.__m_vtkFboItem = rootObject.findChild(FboItem, 'vtkFboItem') # Give the vtkFboItem reference to the CanvasHandler if (self.__m_vtkFboItem): qDebug( 'CanvasHandler::CanvasHandler: setting vtkFboItem to CanvasHandler' ) self.__m_vtkFboItem.rendererInitialized.connect( self.startApplication) else: qCritical( 'CanvasHandler::CanvasHandler: Unable to get vtkFboItem instance' ) return MySettings = QSettings() print("load Settings") self.fileDialog = rootObject.findChild(QObject, "myFileDialog") if (self.fileDialog is not None): tmp = MySettings.value(CanvasHandler.DEFAULT_MODEL_DIR_KEY) print(tmp) self.fileDialog.setProperty("folder", QUrl.fromLocalFile(tmp)) rc = app.exec_() qDebug( f'CanvasHandler::CanvasHandler: Execution finished with return code: {rc}' )