def get_app(key): # send commandline args as message if QT_BINDING == 'pyqt': if len(sys.argv) > 1: app = SingleApplicationWithMessaging(sys.argv, key) if app.isRunning(): msg = json.dumps(sys.argv[1:]) app.sendMessage(msg) _logger.debug('An existing instance of HyperSpyUI is running, ' 'sending arguments to it.') sys.exit(1) # An instance is already running else: app = SingleApplicationWithMessaging(sys.argv, key) if app.isRunning(): _logger.debug('An existing instance of HyperSpyUI is running, ' 'bringing it to the front.') sys.exit(1) # An instance is already running elif QT_BINDING == 'pyside': from siding.singleinstance import QSingleApplication app = QSingleApplication(sys.argv) msg = json.dumps(sys.argv[1:]) app.ensure_single(message=msg) else: app = QtGui.QApplication(sys.argv) return app
def main(): from python_qt_binding import QtGui, QtCore, QT_BINDING import hyperspyui.info from hyperspyui.singleapplication import get_app from hyperspyui.settings import Settings from hyperspyui.util import dummy_context_manager # Need to set early to make QSettings accessible QtCore.QCoreApplication.setApplicationName("HyperSpyUI") QtCore.QCoreApplication.setOrganizationName("Hyperspy") QtCore.QCoreApplication.setApplicationVersion(hyperspyui.info.version) # First, clear all default settings! # TODO: This will cause a concurrency issue with multiple launch Settings.clear_defaults() # Setup default for single/multi-instance settings = Settings(group="General") settings.set_default('allow_multiple_instances', False) if settings['allow_multiple_instances', bool]: # Using multiple instances, get a new application app = QtGui.QApplication(sys.argv) else: # Make sure we only have a single instance app = get_app('hyperspyui') log_file = _get_logfile() if log_file: sys.stdout = sys.stderr = log_file else: log_file = dummy_context_manager() with log_file: # Create and display the splash screen splash_pix = QtGui.QPixmap( os.path.dirname(__file__) + './images/splash.png') splash = QtGui.QSplashScreen(splash_pix, QtCore.Qt.WindowStaysOnTopHint) splash.setMask(splash_pix.mask()) splash.show() app.processEvents() # Need to have import here, as it can take some time, so should happen # after displaying splash from hyperspyui.mainwindow import MainWindow form = MainWindow() if not settings['allow_multiple_instances', bool]: if QT_BINDING == 'pyqt': app.messageAvailable.connect(form.handleSecondInstance) elif QT_BINDING == 'pyside': app.messageReceived.connect(form.handleSecondInstance) form.showMaximized() splash.finish(form) form.load_complete.emit() # Ensure logging is OK import hyperspy.api as hs hs.set_log_level(LOGLEVEL) app.exec_()
def main(): import sys app = QtGui.QApplication(sys.argv) main_window = QtGui.QMainWindow() main_widget = EzPublisherWidget() main_window.setCentralWidget(main_widget) main_window.show() app.exec_()
def main(argv=sys.argv): """The main method for the graph goggles application. * argv -- the command line arguments """ parser = argparse.ArgumentParser( description="View a graph of a dot file through controllable goggles") parser.add_argument( "dot_file", type=str, nargs="?", help="the dot file to load") parser.add_argument( "-d", "--max-distance", type=int, default=10, help="the maximum distance from the node to allow") parser.add_argument( "-v", "--version", action="store_true", help="print the version of the application") args = parser.parse_args() # Handle the version argument if args.version: version = pkg_resources.get_distribution("graph_goggles").version print version exit(0) # Make sure the dot file is provided if args.dot_file is None: print "error: too few arguments" parser.print_help() exit(1) # Grab arguments dotFile = abspath(args.dot_file) maxDistance = args.max_distance # Make sure the dot file exists before continuing if not exists(dotFile): print "ERROR: could not find the dot file: %s" % dotFile exit(1) kwargs = { "dotFile": dotFile, "maxDistance": maxDistance, } app = QtGui.QApplication(argv) window = GraphGogglesWindow(**kwargs) window.show() ret = app.exec_() app.deleteLater() sys.exit(ret)
def main(name): ''' Start the NodeManager or EchoDialog. :param name: the name propagated to the rospy.init_node() :type name: str ''' try: from python_qt_binding import QtGui except: print >> sys.stderr, "please install 'python_qt_binding' package!!" sys.exit(-1) init_settings() parser = init_arg_parser() args = rospy.myargv(argv=sys.argv) parsed_args = parser.parse_args(args[1:]) if parsed_args.muri: masteruri = parsed_args.muri[0] os.environ['ROS_MASTER_URI'] = masteruri hostname = NameResolution.get_ros_hostname(masteruri) if hostname: os.environ['ROS_HOSTNAME'] = hostname masteruri = settings().masteruri() # Initialize Qt global _QAPP _QAPP = QtGui.QApplication(sys.argv) # decide to show main or echo dialog global _MAIN_FORM try: if parsed_args.echo: _MAIN_FORM = init_echo_dialog(name, masteruri, parsed_args.echo[0], parsed_args.echo[1], parsed_args.hz, parsed_args.ssh) else: _MAIN_FORM = init_main_window(name, masteruri, parsed_args.file) except Exception as err: sys.exit("%s" % err) exit_code = 0 # resize and show the qt window if not rospy.is_shutdown(): # change path for access to the images of descriptions os.chdir(settings().PACKAGE_DIR) # _MAIN_FORM.resize(1024, 720) screen_size = QtGui.QApplication.desktop().availableGeometry() if (_MAIN_FORM.size().width() >= screen_size.width() or _MAIN_FORM.size().height() >= screen_size.height() - 24): _MAIN_FORM.showMaximized() else: _MAIN_FORM.show() exit_code = -1 rospy.on_shutdown(finish) exit_code = _QAPP.exec_() return exit_code
def main(name): try: from python_qt_binding import QtGui except: print >> sys.stderr, "please install 'python_qt_binding' package!!" sys.exit(-1) init_settings() masteruri = settings().masteruri() parser = init_arg_parser() args = rospy.myargv(argv=sys.argv) parsed_args = parser.parse_args(args[1:]) # Initialize Qt global app app = QtGui.QApplication(sys.argv) # decide to show main or echo dialog global main_form try: if parsed_args.echo: main_form = init_echo_dialog(name, masteruri, parsed_args.echo[0], parsed_args.echo[1], parsed_args.hz, parsed_args.ssh) else: main_form = init_main_window(name, masteruri, parsed_args.file) except Exception as e: sys.exit("%s" % e) exit_code = 0 # resize and show the qt window if not rospy.is_shutdown(): os.chdir(settings().PACKAGE_DIR ) # change path to be able to the images of descriptions # main_form.resize(1024, 720) screen_size = QtGui.QApplication.desktop().availableGeometry() if main_form.size().width() >= screen_size.width() or main_form.size( ).height() >= screen_size.height() - 24: main_form.showMaximized() else: main_form.show() exit_code = -1 rospy.on_shutdown(finish) exit_code = app.exec_() return exit_code
def launch_standalone(name, GuiT, RosT, resource=""): import rospy, os, sys import python_qt_binding as pyqt from python_qt_binding import QtGui app = QtGui.QApplication(sys.argv) rospy.init_node(name, sys.argv) gui = GuiT() ros = RosT() if resource == "": resource = _resource(name) #Load the UI pyqt.loadUi(resource, gui) #Connect the user interface and ROS ros.setup(gui) gui.setup(name, ros) #Start GUI gui.show() sys.exit(app.exec_())
def get_app(key): # send commandline args as message if QT_BINDING == 'pyqt': if len(sys.argv) > 1: app = SingleApplicationWithMessaging(sys.argv, key) if app.isRunning(): msg = json.dumps(sys.argv[1:]) app.sendMessage(msg) sys.exit(1) # An instance is already running else: app = SingleApplicationWithMessaging(sys.argv, key) if app.isRunning(): sys.exit(1) # An instance is already running elif QT_BINDING == 'pyside': from siding.singleinstance import QSingleApplication app = QSingleApplication(sys.argv) msg = json.dumps(sys.argv[1:]) app.ensure_single(message=msg) else: app = QtGui.QApplication(sys.argv) return app
def timeoutRunning(self): self.qt_display.timeoutRunning() self.qt_plot.timeMeasuresEvent() def cb_status(self, msg_status): txt_status = '' if msg_status.laser_on: txt_status = 'Laser ON' + '\n' # self.lblStatus.setStyleSheet( # "background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);") else: txt_status = 'Laser OFF' + '\n' # self.lblStatus.setStyleSheet( # "background-color: rgb(255, 255, 0); color: rgb(0, 0, 0);") self.lblStatus.setText(txt_status) def btnQuitClicked(self): QtCore.QCoreApplication.instance().quit() if __name__ == '__main__': import sys rospy.init_node('cladviz') app = QtGui.QApplication(sys.argv) cladviz = CladViz() cladviz.show() sys.exit(app.exec_())
#time.sleep(0.5) def shutdown_plugin(self): # TODO unregister all publishers here if self.s: self.s.stop() def save_settings(self, plugin_settings, instance_settings): # TODO save intrinsic configuration, usually using: # instance_settings.set_value(k, v) pass def restore_settings(self, plugin_settings, instance_settings): # TODO restore intrinsic configuration, usually using: # v = instance_settings.value(k) pass #def trigger_configuration(self): # Comment in to signal that the plugin has a way to configure # This will enable a setting button (gear icon) in each dock widget title bar # Usually used to open a modal configuration dialog if __name__ == "__main__": app = QtGui.QApplication([]) window = QWidget() layout = QtGui.QVBoxLayout(window) #a = SpheroControl(layout) a = SpheroControl() a._widget.show() sys.exit(app.exec_())
def main(): app = QtGui.QApplication(sys.argv) # A new instance of QApplication app.setStyleSheet(qdarkstyle.load_stylesheet(pyside=False)) form = ExampleApp() # We set the form to be our ExampleApp (design) form.show() # Show the form app.exec_() # and execute the app