コード例 #1
0
ファイル: ui.py プロジェクト: eepp/yobr
def main():
    # refresh timer timeout
    def refresh_timer_timeout():
        logger.info('Updating package build monitor.')
        pkg_build_monitor.update()

    try:
        # create application
        app = qtwidgets.QApplication(sys.argv)
        app.setApplicationName('YO Buildroot!')
        app.setApplicationVersion(yobr.__version__)

        # setup signals
        _setup_signals()

        # parse and validate command-line arguments
        args = _parse_args(app)
        _validate_args(args)

        # configure logging
        logging.basicConfig(
            level=args.log_level,
            style='{',
            format='{asctime} [{name}] {{{levelname}}}: {message}')
        logger = logging.getLogger('main')

        # query Buildroot for package information
        logger.info('Starting application (v{}).'.format(yobr.__version__))
        logger.info('Getting package information from `{}`.'.format(
            args.br_root_dir))
        pkg_builds = yobr.br.pkg_builds_from_make(args.br_root_dir,
                                                  args.br_build_dir)
        pkg_build_monitor = _PkgBuildMonitor(pkg_builds)

        if len(pkg_build_monitor.pkg_builds) == 0:
            # weird
            raise RuntimeError('No packages found!')

        logger.info('Watching {} packages:'.format(
            len(pkg_build_monitor.pkg_builds)))

        for pkg_build in sorted(pkg_build_monitor.pkg_builds.values(),
                                key=lambda pb: pb.build_dir):
            logger.info('  `{}` ({} dependencies)'.format(
                pkg_build.build_dir, len(pkg_build.info.dependencies)))

        # create window
        logger.info('Starting UI.')
        w = _YoBrWindow(app, pkg_build_monitor)

        # connect "Refresh now" action
        w.refresh_action.triggered.connect(refresh_timer_timeout)

        # create refresh timer: initial interval is 2 s
        timer = qtcore.QTimer(app)
        timer.setInterval(2000)
        timer.timeout.connect(refresh_timer_timeout)

        # connect interval change signal
        w.refresh_interval_changed.connect(timer.setInterval)

        # start timer
        timer.start()

        # initial update
        pkg_build_monitor.update()

        # show window
        w.show()

        # we're done
        sys.exit(app.exec_())
    except Exception as exc:
        _perror(str(exc))
        sys.exit(1)
コード例 #2
0
ファイル: gui.py プロジェクト: HellFly/Project-AC
import sys
import PyQt5 as PyQt
#from PyQt5.QtWidgets import QApplication, QDialog
from designs.index import index

app = PyQt.QApplication(sys.argv)
window = PyQt.QDialog()
ui = index()
ui.setupUi(window)

window.show()
sys.exit(app.exec_())