def start(): # Start the Qt main object app = QApplication([]) # Start the bluesky network client client = GuiClient() # Enable HiDPI support (Qt5 only) if QT_VERSION >= 0x050000: app.setAttribute(Qt.AA_UseHighDpiPixmaps) splash = Splash() # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMCUSTOMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print(( 'Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))) splash.show() # Install error message handler handler = QErrorMessage.qtHandler() handler.setWindowFlags(Qt.WindowStaysOnTopHint) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))) splash.showMessage('Constructing main window') app.processEvents() win = MainWindow() win.show() splash.showMessage('Done!') app.processEvents() splash.finish(win) # If this instance of the gui is started in client-only mode, show # server selection dialog if bs.settings.is_client: dialog = DiscoveryDialog(win) dialog.show() bs.net.start_discovery() else: client.connect(event_port=bs.settings.event_port, stream_port=bs.settings.stream_port) # Start the Qt main loop app.exec_()
def start(mode): # Install message handler for Qt messages qInstallMessageHandler(gui_msg_handler) # Start the Qt main object app = QApplication([]) # Start the bluesky network client client = GuiClient() # Enable HiDPI support (Qt5 only) if QT_VERSION >= 0x050000: app.setAttribute(Qt.AA_UseHighDpiPixmaps) splash = Splash() # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMCUSTOMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print(('Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))) splash.show() # Install error message handler handler = QErrorMessage.qtHandler() handler.setWindowFlags(Qt.WindowStaysOnTopHint) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))) splash.showMessage('Constructing main window') app.processEvents() win = MainWindow(mode) win.show() splash.showMessage('Done!') app.processEvents() splash.finish(win) # If this instance of the gui is started in client-only mode, show # server selection dialog if mode == 'client': dialog = DiscoveryDialog(win) dialog.show() bs.net.start_discovery() else: client.connect(event_port=bs.settings.event_port, stream_port=bs.settings.stream_port) # Start the Qt main loop app.exec_()
def start(hostname=None): # Install message handler for Qt messages qInstallMessageHandler(gui_msg_handler) # Start the Qt main object app = QApplication([]) # Explicitly set font to avoid font loading warning dialogs app.setFont(QFont('Sans')) # Start the bluesky network client client = GuiClient() # Enable HiDPI support (Qt5 only) if QT_VERSION_STR[0] == '5' and QT_VERSION >= 0x050000: app.setAttribute(Qt.AA_UseHighDpiPixmaps) splash = Splash() # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMCUSTOMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print(( 'Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))) splash.show() # Install error message handler # handler = QErrorMessage.qtHandler() # handler.setWindowFlags(Qt.WindowType.WindowStaysOnTopHint) splash.showMessage('Constructing main window') app.processEvents() win = MainWindow(bs.mode) win.show() splash.showMessage('Done!') app.processEvents() splash.finish(win) # If this instance of the gui is started in client-only mode, show # server selection dialog if bs.mode == 'client' and hostname is None: dialog = DiscoveryDialog(win) dialog.show() bs.net.start_discovery() else: client.connect(hostname=hostname) # Start the Qt main loop # app.exec_() app.exec()
def start(mode): # Install message handler for Qt messages qInstallMessageHandler(gui_msg_handler) # Start the Qt main object app = QApplication([]) # Start the bluesky network client client = GuiClient() # Enable HiDPI support (Qt5 only) if QT_VERSION >= 0x050000: app.setAttribute(Qt.AA_UseHighDpiPixmaps) splash = Splash() # Register our custom pan/zoom event for etype in range(1000, 1000 + NUMCUSTOMEVENTS): reg_etype = QEvent.registerEventType(etype) if reg_etype != etype: print(( 'Warning: Registered event type differs from requested type id (%d != %d)' % (reg_etype, etype))) splash.show() # Install error message handler handler = QErrorMessage.qtHandler() handler.setWindowFlags(Qt.WindowStaysOnTopHint) # Check and set OpenGL capabilities if not QGLFormat.hasOpenGL(): raise RuntimeError('No OpenGL support detected for this system!') else: f = QGLFormat() f.setVersion(3, 3) f.setProfile(QGLFormat.CoreProfile) f.setDoubleBuffer(True) QGLFormat.setDefaultFormat(f) print(('QGLWidget initialized for OpenGL version %d.%d' % (f.majorVersion(), f.minorVersion()))) splash.showMessage('Constructing main window') app.processEvents() win = MainWindow(mode) splash.showMessage('Done!') app.processEvents() splash.finish(win) # Quick hack to connect to a remote simulation import sys arg = '--bluesky_host=' host = next((x for x in sys.argv if x.startswith(arg)), None) if host is not None: host = host[len(arg):] try: print('Attempting connection to BlueSky at: {}'.format(host)) client.connect(hostname=host, event_port=bs.settings.event_port, stream_port=bs.settings.stream_port, timeout=5) except TimeoutError: print('Failed to connect to BlueSky server at {}, exiting'.format( host)) QApplication.quit() sys.exit(0) win.show() app.exec_() return win.show() # If this instance of the gui is started in client-only mode, show # server selection dialog if mode == 'client': dialog = DiscoveryDialog(win) dialog.show() bs.net.start_discovery() else: client.connect(event_port=bs.settings.event_port, stream_port=bs.settings.stream_port) # Start the Qt main loop app.exec_()