Esempio n. 1
0
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
Esempio n. 2
0
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_()
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
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_())
Esempio n. 6
0
def get_qapp():
    """ Return a QApplication instance, creating one if needed. """
    from qtpy.QtWidgets import QApplication
    qapp = QApplication.instance()
    if qapp:
        return qapp
    qapp = QApplication(sys.argv)
    qapp.setApplicationName('MoView')
    qapp.setApplicationDisplayName('MoView')
    qapp.setApplicationVersion(__version__)
    return qapp
Esempio n. 7
0
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_()
Esempio n. 8
0
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_()
Esempio n. 9
0
        os.environ["QT_QPA_PLATFORM"] = "offscreen"
    if getattr(sys, 'frozen', False):
        application_path = os.path.dirname(sys.executable)
    elif __file__:
        application_path = os.path.dirname(__file__)
    else:
        application_path = "."
    logging.debug("Application path is {}".format(application_path))
    os.chdir(application_path)
    sys.path.insert(0, os.path.abspath(MODULES_PATH))
    sys.path.append(os.path.abspath(CLIENT_PATH))

    QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QApplication.setQuitOnLastWindowClosed(False)

    app = QApplication(sys.argv)
    app.setApplicationName(__app_name__)
    app.setApplicationVersion(__version__)
    app.setApplicationDisplayName(__app_name__)

    app.setStyleSheet(qrainbowstyle.load_stylesheet(style="Oceanic"))
    font = app.font()
    font.setPointSize(9)
    app.setFont(font)

    m = Main(args)
    m.connect_log_signal(logger.install_signal_handler())

    sys.exit(app.exec_())
Esempio n. 10
0
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_()
Esempio n. 11
0
def main(args=None):
    ap = argparse.ArgumentParser(
        usage=__doc__.splitlines()[0],
        epilog="You can also pass any command line arguments supported by Qt.",
    )
    ap.add_argument(
        "-d",
        "--debug",
        action="store_true",
        help="Enable debug logging.",
    )
    ap.add_argument(
        "-n",
        "--client-name",
        metavar="NAME",
        default=PROGRAM,
        help="Set JACK client name to NAME (default: '%(default)s')",
    )
    ap.add_argument(
        "-i",
        "--connect-interval",
        type=posnum,
        default=3.0,
        metavar="SECONDS",
        help="Interval between attempts to connect to JACK server "
        " (default: %(default)s)",
    )
    ap.add_argument(
        "-m",
        "--max-attempts",
        type=posnum,
        default=1,
        metavar="NUM",
        help="Max. number of attempts to connect to JACK server "
        "(0=infinite, default: %(default)s)).",
    )
    cargs, args = ap.parse_known_args(args)

    # App initialization
    app = QApplication(args)
    app.setApplicationName(PROGRAM)
    app.setApplicationVersion(__version__)
    app.setOrganizationName(ORGANIZATION)
    app.setWindowIcon(QIcon(":/icons//scalable/qjackcapture.svg"))

    logging.basicConfig(
        level=logging.DEBUG if cargs.debug else logging.INFO,
        format="%(name)s:%(levelname)s: %(message)s",
    )

    if jacklib is None:
        QMessageBox.critical(
            None,
            app.translate(PROGRAM, "Error"),
            app.translate(
                PROGRAM,
                "JACK is not available in this system, cannot use this application.",
            ),
        )
        return 1

    if not gJackCapturePath:
        QMessageBox.critical(
            None,
            app.translate(PROGRAM, "Error"),
            app.translate(
                PROGRAM,
                "The 'jack_capture' application is not available.\n"
                "Is not possible to render without it!",
            ),
        )
        return 2

    try:
        jack_client = QJackCaptureClient(
            cargs.client_name + "-ui",
            connect_interval=cargs.connect_interval,
            connect_max_attempts=cargs.max_attempts,
        )
    except KeyboardInterrupt:
        log.info("Aborted.")
        return 1
    except Exception as exc:
        QMessageBox.critical(
            None,
            app.translate(PROGRAM, "Error"),
            app.translate(
                PROGRAM,
                "Could not connect to JACK, possible reasons:\n%s\n\n"
                "See console log for more information.",
            ) % exc,
        )
        return 1

    # Show GUI
    gui = QJackCaptureMainWindow(None, jack_client, cargs.client_name)
    gui.setWindowIcon(get_icon("media-record", 48))
    gui.show()

    # Main loop
    return app.exec_()