예제 #1
0
def main():
    opts = docopt(__doc__)
    logging.basicConfig(
        level=logging.WARN if opts['--quiet'] else logging.INFO,
        stream=sys.stderr, format='%(name)s: %(message)s'
    )

    # Create GUI or non-GUI application as appropriate
    if opts['--no-gui']:
        app = QtCore.QCoreApplication(sys.argv)
    else:
        app = QtGui.QApplication(sys.argv)

    # Wire up Ctrl-C to quit app.
    def interrupt(*args):
        print('received interrupt signal, exitting...')
        app.quit()
    signal.signal(signal.SIGINT, interrupt)

    # Create the main simulator and attach it to application quit events.
    sim = create_sim(opts)

    # Stop simulating when app is quitting
    app.aboutToQuit.connect(sim.stop)

    # Create the sim UI if requested
    if not opts['--no-gui']:
        ui = create_ui(sim)

    # Start simulating once event loop is running
    QtCore.QTimer.singleShot(0, sim.start)

    # Start the application
    sys.exit(app.exec_())
예제 #2
0
def main():
    app = QtCore.QCoreApplication(sys.argv)

    args = app.arguments()

    sim = Simulator(str(args[-2]), int(args[-1]))

    signal.signal(signal.SIGINT, sim.close)

    sys.exit(app.exec_())
예제 #3
0
    def run(self):
        app = QtCore.QCoreApplication([])
        server_manager = ServerManager()
        server_manager.server.start(self.port)

        # start thread which listens on the child_connection
        t = Thread(target=self.listen, args=(app, server_manager))
        t.start()

        # run event loop of app
        app.exec_()
예제 #4
0
def test_get_name(player_uuid):
    global app
    if app is None:
        app = QtCore.QCoreApplication([])
    #loop = QtCore.QEventLoop()
    obj = {}

    def callback(result, error):
        obj['result'] = result
        assert result
        app.exit()

    PlayerDataCache.getPlayerInfo(player_uuid, callback)

    app.exec_()
예제 #5
0
import time
import sys

try:
    from PySide import QtCore  # @UnresolvedImport
except:
    from PyQt4 import QtCore


# Subclassing QThread
# http://doc.qt.nokia.com/latest/qthread.html
class AThread(QtCore.QThread):
    def run(self):
        count = 0
        while count < 5:
            time.sleep(.5)
            print("Increasing", count)
            sys.stdout.flush()
            count += 1


app = QtCore.QCoreApplication([])
thread = AThread()
thread.finished.connect(app.exit)
thread.start()
app.exec_()
print('TEST SUCEEDED!')
예제 #6
0
    def killYourSelf(self, current=None):
        self.handler.killYourSelf()

    def getAttrList(self, current=None):
        try:
            return self.handler.getAttrList()
        except:
            print 'Problem getting getAttrList'
            traceback.print_exc()
            status = 1
            return


if __name__ == '__main__':
    app = QtCore.QCoreApplication(sys.argv)
    params = copy.deepcopy(sys.argv)
    if len(params) > 1:
        if not params[1].startswith('--Ice.Config='):
            params[1] = '--Ice.Config=' + params[1]
    elif len(params) == 1:
        params.append('--Ice.Config=config')
    ic = Ice.initialize(params)
    status = 0
    mprx = {}
    parameters = {}
    for i in ic.getProperties():
        parameters[str(i)] = str(ic.getProperties().getProperty(i))

    # Remote object connection for DifferentialRobot
    try:
예제 #7
0
def main():
    """
    Parse any input arguments and run the application
    """

    # Enable multiprocessing on windows frozen binaries. Does nothing on other systems
    multiprocessing.freeze_support()

    # Parse input arguments to pass info to GUI
    parser = argparse.ArgumentParser()
    parser.add_argument('data', help='Load data files', nargs="*", type=str)
    parser.add_argument('--batch', help='Run batch file', default=None, type=str)
    parser.add_argument('--debug', help='Activate debug mode', action="store_true")
    parser.add_argument('--test-all', help='Run all tests', action="store_true")
    parser.add_argument('--test', help='Specify test suite to be run (default=run all)', default=None)
    parser.add_argument('--test-fast', help='Run only fast tests', action="store_true")
    parser.add_argument('--qv', help='Activate quick-view mode', action="store_true")
    parser.add_argument('--register', help='Force display of registration dialog', action="store_true")
    args = parser.parse_args()

    # Apply global options
    if args.debug:
        set_base_log_level(logging.DEBUG)
    else:
        set_base_log_level(logging.WARN)

    if args.register:
        QtCore.QSettings().setValue("license_accepted", 0)

    # Set the local file path, used for finding icons, plugins, etc
    set_local_file_path()

    # Handle CTRL-C correctly
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    if args.batch is not None:
        # Batch runs need a QCoreApplication to avoid initializing the GUI - this
        # would fail when running on a displayless system 
        app = QtCore.QCoreApplication(sys.argv)
        runner = BatchScript()
        # Add delay to make sure script is run after the main loop starts, in case
        # batch script is completely synchronous
        QtCore.QTimer.singleShot(200, lambda: runner.execute({"yaml-file" : args.batch}))
        sys.exit(app.exec_())
    else:
        # Otherwise we need a QApplication and to initialize the GUI
        
        if sys.platform.startswith("darwin") and PYSIDE1:
            # Required on Mac with Pyside 1
            QtGui.QApplication.setGraphicsSystem('native')

        app = QtGui.QApplication(sys.argv)
        app.setStyle('plastique')
        QtCore.QCoreApplication.setOrganizationName("ibme-qubic")
        QtCore.QCoreApplication.setOrganizationDomain("eng.ox.ac.uk")
        QtCore.QCoreApplication.setApplicationName("Quantiphyse")
        QtGui.QApplication.setWindowIcon(QtGui.QIcon(get_icon("main_icon.png")))

        if args.debug:
            import pyqtgraph as pg
            pg.systemInfo()

        if args.test_all or args.test:
            # Run tests
            run_tests(args.test)
            sys.exit(0)
        else:
            # Create window and start main loop
            pixmap = QtGui.QPixmap(get_icon("quantiphyse_splash.png"))
            splash = QtGui.QSplashScreen(pixmap)
            splash.show()
            app.processEvents()

            win = MainWindow(load_data=args.data, widgets=not args.qv)
            splash.finish(win)
            sys.excepthook = my_catch_exceptions
            set_main_window(win)
            register.check_register()
            sys.exit(app.exec_())
예제 #8
0
    def write(self, data):
        packed = msgpack.packb(data)
        datagram = QtCore.QByteArray(packed)
        self.socket.writeDatagram(datagram, QtNetwork.QHostAddress.LocalHost,
                                  3020)
        #print "wrote %d bytes" % datagram.size()

    @QtCore.Slot()
    def demo_write(self):
        for strand in range(5):
            r, g, b = [
                int(255.0 * c) for c in colorsys.hsv_to_rgb(
                    math.fmod((self.h + (0.2 * strand)), 1.0), 1.0, 1.0)
            ]
            self.write([strand, -1, -1, r, g, b])
        self.h += 0.004


def sigint_handler(signal, frame):
    global app
    app.exit()


if __name__ == "__main__":
    signal.signal(signal.SIGINT, sigint_handler)
    app = QtCore.QCoreApplication(["testserver"])
    print "Press Ctrl-C to quit"
    nc = TestServer()
    nc.init_socket()
    app.exec_()