Ejemplo n.º 1
0
def run():
    '''Run the main application.'''

    # nasty workaround for bug that causes non-modal windows not to
    # appear on mac see
    # https://github.com/jeremysanders/veusz/issues/39
    if sys.platform == 'darwin':
        import glob
        for f in glob.glob(
                os.environ['HOME'] +
                '/Library/Saved Application State/org.python.veusz.*/*'):
            os.unlink(f)

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # this function is spaghetti-like and has nasty code paths.
    # the idea is to postpone the imports until the splash screen
    # is shown

    app = VeuszApp(sys.argv)
    app.startup()
    app.exec_()
Ejemplo n.º 2
0
def run():
    '''Run the main application.'''

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # this function is spaghetti-like and has nasty code paths.
    # the idea is to postpone the imports until the splash screen
    # is shown

    app = qt4.QApplication(sys.argv)
    app.connect(app, qt4.SIGNAL('lastWindowClosed()'), app, qt4.SLOT('quit()'))

    # register a signal handler to catch ctrl+C
    signal.signal(signal.SIGINT, handleIntSignal)

    # parse command line options
    parser = optparse.OptionParser(usage='%prog [options] filename.vsz ...',
                                   version=copyr % utils.version())
    parser.add_option('--unsafe-mode',
                      action='store_true',
                      help='disable safety checks when running documents'
                      ' or scripts')
    parser.add_option('--listen',
                      action='store_true',
                      help='read and execute Veusz commands from stdin,'
                      ' replacing veusz_listen')
    parser.add_option('--quiet',
                      action='store_true',
                      help='if in listening mode, do not open a window but'
                      ' execute commands quietly')
    parser.add_option('--export',
                      action='append',
                      metavar='FILE',
                      help='export the next document to this'
                      ' output image file, exiting when finished')
    parser.add_option('--embed-remote',
                      action='store_true',
                      help=optparse.SUPPRESS_HELP)
    parser.add_option('--plugin',
                      action='append',
                      metavar='FILE',
                      help='load the plugin from the file given for '
                      'the session')
    parser.add_option('--translation',
                      metavar='FILE',
                      help='load the translation .qm file given')
    options, args = parser.parse_args(app.argv())

    # convert args to unicode from filesystem strings
    args = convertArgsUnicode(args)

    s = AppRunner(options, args)
    app.exec_()
Ejemplo n.º 3
0
def run():
    '''Run the main application.'''

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # this function is spaghetti-like and has nasty code paths.
    # the idea is to postpone the imports until the splash screen
    # is shown

    app = qt4.QApplication(sys.argv)
    app.connect(app, qt4.SIGNAL('lastWindowClosed()'),
                app, qt4.SLOT('quit()'))

    # register a signal handler to catch ctrl+C
    signal.signal(signal.SIGINT, handleIntSignal)

    # parse command line options
    parser = optparse.OptionParser(
        usage='%prog [options] filename.vsz ...',
        version=copyr % utils.version())
    parser.add_option('--unsafe-mode', action='store_true',
                      help='disable safety checks when running documents'
                      ' or scripts')
    parser.add_option('--listen', action='store_true',
                      help='read and execute Veusz commands from stdin,'
                      ' replacing veusz_listen')
    parser.add_option('--quiet', action='store_true',
                      help='if in listening mode, do not open a window but'
                      ' execute commands quietly')
    parser.add_option('--export', action='append', metavar='FILE',
                      help='export the next document to this'
                      ' output image file, exiting when finished')
    parser.add_option('--embed-remote', action='store_true',
                      help=optparse.SUPPRESS_HELP)
    parser.add_option('--plugin', action='append', metavar='FILE',
                      help='load the plugin from the file given for '
                      'the session')
    parser.add_option('--translation', metavar='FILE',
                      help='load the translation .qm file given')
    options, args = parser.parse_args( app.argv() )

    # convert args to unicode from filesystem strings
    args = convertArgsUnicode(args)

    s = AppRunner(options, args)
    app.exec_()
Ejemplo n.º 4
0
def run():
    '''Run the main application.'''

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # this function is spaghetti-like and has nasty code paths.
    # the idea is to postpone the imports until the splash screen
    # is shown

    app = VeuszApp()
    app.startup()
    app.exec_()
Ejemplo n.º 5
0
def run():
    '''Run the main application.'''

    # high DPI support
    try:
        qt.QApplication.setAttribute(qt.Qt.AA_EnableHighDpiScaling, True)
        qt.QApplication.setAttribute(qt.Qt.AA_UseHighDpiPixmaps, True)
    except AttributeError:
        # old qt versions
        pass

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # start me up
    app = VeuszApp()
    app.startup()
    app.exec_()
Ejemplo n.º 6
0
def run():
    '''Run the main application.'''

    # nasty workaround for bug that causes non-modal windows not to
    # appear on mac see
    # https://github.com/jeremysanders/veusz/issues/39
    if sys.platform == 'darwin':
        import glob
        for f in glob.glob(os.environ['HOME'] + '/Library/Saved Application State/org.python.veusz.*/*'):
            os.unlink(f)

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # this function is spaghetti-like and has nasty code paths.
    # the idea is to postpone the imports until the splash screen
    # is shown

    app = VeuszApp(sys.argv)
    app.startup()
    app.exec_()
Ejemplo n.º 7
0
def run():
    '''Run the main application.'''

    # jump to the embedding client entry point if required
    if len(sys.argv) == 2 and sys.argv[1] == '--embed-remote':
        from veusz.embed_remote import runremote
        runremote()
        return

    # this function is spaghetti-like and has nasty code paths.
    # the idea is to postpone the imports until the splash screen
    # is shown

    app = qt4.QApplication(sys.argv)
    app.connect(app, qt4.SIGNAL("lastWindowClosed()"),
                app, qt4.SLOT("quit()"))
    sys.excepthook = excepthook

    # register a signal handler to catch ctrl+C
    signal.signal(signal.SIGINT, handleIntSignal)

    # parse command line options
    parser = optparse.OptionParser(
        usage="%prog [options] filename.vsz ...",
        version=copyr % utils.version())
    parser.add_option('--unsafe-mode', action='store_true',
                      help='disable safety checks when running documents'
                      ' or scripts')
    parser.add_option('--listen', action='store_true',
                      help='read and execute Veusz commands from stdin,'
                      ' replacing veusz_listen')
    parser.add_option('--quiet', action='store_true',
                      help='if in listening mode, do not open a window but'
                      ' execute commands quietly')
    parser.add_option('--export', action='append', metavar='FILE',
                      help='export the next document to this'
                      ' output image file, exiting when finished')
    parser.add_option('--embed-remote', action='store_true',
                      help=optparse.SUPPRESS_HELP)
    parser.add_option('--plugin', action='append', metavar='FILE',
                      help='load the plugin from the file given for '
                      'the session')
    options, args = parser.parse_args( app.argv() )

    # convert args to unicode from filesystem strings
    args = convertArgsUnicode(args)

    splash = None
    if options.listen or options.export:
        # do not show splash screen
        spash = None
    else:
        splash = qt4.QSplashScreen(makeSplashLogo())
        splash.show()
        app.processEvents()

    # import these after showing splash screen so we don't
    # have too long a wait before it shows
    import veusz.setting
    import veusz.widgets

    # for people who want to run any old script
    veusz.setting.transient_settings['unsafe_mode'] = bool(
        options.unsafe_mode)

    # load any requested plugins
    if options.plugin:
        import veusz.document
        veusz.document.Document.loadPlugins(pluginlist=options.plugin)

    # different modes
    if options.listen:
        # listen to incoming commands
        listen(args, quiet=options.quiet)
    elif options.export:
        # export files to make images
        if len(options.export) != len(args)-1:
            parser.error(
                'export option needs same number of documents and output files')
        export(options.export, args)
        return
    else:
        # standard start main window
        mainwindow(args)

    # clear splash when startup done
    if splash is not None:
        splash.finish(app.topLevelWidgets()[0])

    # wait for application to exit
    app.exec_()