示例#1
0
        drinks.items.append(drink)

    uidmap = UidService()
    cart = Cart(uidmap)

    app = QGuiApplication(sys.argv)

    for trfile in ['view_de.qm']:
        translator = QTranslator()

        translator.load(os.path.join("i18n", trfile))

        app.installTranslator(translator)

    font = QFont("Helvetica", 16)
    app.setFont(font)
    view = QQuickView()
    view.width = 800
    view.height = 460
    view.setResizeMode(QQuickView.SizeRootObjectToView)

    # Expose the data to the Qml code
    ctx = view.rootContext()
    ctx.setContextProperty("drinks", drinks)
    ctx.setContextProperty("cart", cart)
    ctx.setContextProperty("logbook", cart.log)
    ctx.setContextProperty("uidmap", uidmap)
    ctx.setContextProperty("dayFee", DAY_FEE)

    qml_file = os.path.join(os.path.dirname(__file__), "view.qml")
    view.setSource(QUrl.fromLocalFile(os.path.abspath(qml_file)))
示例#2
0
        captcha_img_local_url = 'file://' + self._captcha_img_file.name

        self._scihub_captcha.showWindowCaptcha.emit(captcha_img_local_url)

    def log(self, message, level=None):
        self.appendLogs.emit(message, level)


if __name__ == '__main__':
    app_path = os.path.abspath(os.path.dirname(sys.argv[0]))
    os.environ['QT_QUICK_CONTROLS_CONF'] = os.path.join(
        app_path, 'qtquickcontrols2.conf')

    app = QGuiApplication(sys.argv)

    lang = locale.getdefaultlocale()[0]
    lang_file_path = os.path.join(
        app_path, 'translations/SciHubEVA_{lang}.qm'.format(lang=lang))
    translator = QTranslator()
    translator.load(lang_file_path)
    app.installTranslator(translator)

    icon_file_path = os.path.join(app_path, 'images/SciHubEVA-icon.png')
    app.setWindowIcon(QIcon(icon_file_path))

    if sys.platform == 'win32':
        app.setFont(QFont('Microsoft YaHei'))

    eva = SciHubEVA()
    sys.exit(app.exec_())
示例#3
0
        PREFERENCES_DIR / 'qtquickcontrols2.conf').resolve().as_posix()

    QCoreApplication.setOrganizationName(ORGANIZATION_NAME)
    QCoreApplication.setOrganizationDomain(ORGANIZATION_DOMAIN)
    QCoreApplication.setApplicationName(APPLICATION_NAME)

    QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QGuiApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    QGuiApplication.setAttribute(Qt.AA_ShareOpenGLContexts)

    app = QGuiApplication(sys.argv)

    lang = Preferences.get_or_default(SYSTEM_LANGUAGE_KEY, SYSTEM_LANGUAGE)
    lang_file_path = (
        I18N_DIR /
        'SciHubEVA_{lang}.qm'.format(lang=lang)).resolve().as_posix()
    translator = QTranslator()
    translator.load(lang_file_path)
    app.installTranslator(translator)

    icon_file_path = (IMAGES_DIR / 'SciHubEVA-icon.png').resolve().as_posix()
    app.setWindowIcon(QIcon(icon_file_path))

    if is_windows():
        app.setFont(QFont('Microsoft YaHei UI'))
    elif is_macos():
        app.setFont(QFont('PingFang SC'))

    eva = UISciHubEVA()
    sys.exit(app.exec_())