Ejemplo n.º 1
0
def main():
    app = QApplication(sys.argv)

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setApplicationName("html2pdf")
    QCoreApplication.setApplicationVersion(__qt_version__)

    parser = QCommandLineParser()
    parser.setApplicationDescription(
        QCoreApplication.translate(
            "main", "Converts the web page INPUT into the PDF file OUTPUT."))
    parser.addHelpOption()
    parser.addVersionOption()
    parser.addPositionalArgument(
        QCoreApplication.translate("main", "INPUT"),
        QCoreApplication.translate("main", "Input URL for PDF conversion."),
    )
    parser.addPositionalArgument(
        QCoreApplication.translate("main", "OUTPUT"),
        QCoreApplication.translate("main",
                                   "Output file name for PDF conversion."),
    )

    parser.process(QCoreApplication.arguments())

    requiredArguments = parser.positionalArguments()
    if len(requiredArguments) != 2:
        parser.showHelp(1)

    converter = Html2PdfConverter(*requiredArguments[:2])
    ret = converter.run()
    sys.exit(ret)
Ejemplo n.º 2
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    # QtWebEngine::initialize()

    if QT_NO_WIDGETS:
        app = QApplication(sys.argv)
    else:
        app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()
    server = Server(engine)

    engine.load(QUrl("qrc:/main.qml"))
    QTimer.singleShot(0, server.run)

    proxy = QNetworkProxy()
    proxy.setType(QNetworkProxy.HttpProxy)
    proxy.setHostName("localhost")
    proxy.setPort(5555)
    QNetworkProxy.setApplicationProxy(proxy)

    sys.exit(app.exec_())
Ejemplo n.º 3
0
def main():
    import sys

    app = QApplication(sys.argv)

    QQuickWindow.setDefaultAlphaBuffer(True)

    QCoreApplication.setApplicationName("Photosurface")
    QCoreApplication.setOrganizationName("QtProject")
    QCoreApplication.setApplicationVersion(__qt_version__)
    parser = QCommandLineParser()
    parser.setApplicationDescription("Qt Quick Demo - Photo Surface")
    parser.addHelpOption()
    parser.addVersionOption()
    parser.addPositionalArgument("directory", "The image directory or URL to show.")
    parser.process(app)

    initialUrl = QUrl()
    if parser.positionalArguments():
        initialUrl = QUrl.fromUserInput(
            parser.positionalArguments()[0], QDir.currentPath(), QUrl.AssumeLocalFile
        )
        if not initialUrl.isValid():
            print(
                'Invalid argument: "',
                parser.positionalArguments()[0],
                '": ',
                initialUrl.errorString(),
            )
            sys.exit(1)

    nameFilters = imageNameFilters()

    engine = QQmlApplicationEngine()
    context: QQmlContext = engine.rootContext()

    picturesLocationUrl = QUrl.fromLocalFile(QDir.homePath())
    picturesLocations = QStandardPaths.standardLocations(
        QStandardPaths.PicturesLocation
    )
    if picturesLocations:
        picturesLocationUrl = QUrl.fromLocalFile(picturesLocations[0])
        if not initialUrl and QDir(picturesLocations[0]).entryInfoList(
            nameFilters, QDir.Files
        ):
            initialUrl = picturesLocationUrl

    context.setContextProperty("contextPicturesLocation", picturesLocationUrl)
    context.setContextProperty("contextInitialUrl", initialUrl)
    context.setContextProperty("contextImageNameFilters", nameFilters)

    engine.load(QUrl("qrc:///photosurface.qml"))
    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Ejemplo n.º 4
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QApplication(sys.argv)

    w = MainWindow()
    w.show()

    sys.exit(app.exec_())
Ejemplo n.º 5
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    # QtWebEngine::initialize()

    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.load(QUrl("qrc:/WebBrowser.qml"))

    sys.exit(app.exec_())
Ejemplo n.º 6
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

    app = QApplication(sys.argv)
    w = MainWindow(QUrl("http://qt.io"))
    w.resize(1024, 768)
    w.show()

    sys.exit(app.exec_())
Ejemplo n.º 7
0
def main() -> None:
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QApplication(sys.argv)

    view = QWebEngineView()
    view.setUrl(commandLineUrlArgument())
    view.resize(1024, 750)
    view.show()

    sys.exit(app.exec_())
Ejemplo n.º 8
0
def main():
    import sys

    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QCoreApplication.setOrganizationName("QtExamples")

    app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()
    engine.addImportPath(":/imports")
    engine.load(QUrl("qrc:/main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Ejemplo n.º 9
0
def main():
    import sys

    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QCoreApplication.setOrganizationName("QtExamples")

    app = QGuiApplication(sys.argv)

    view = QQuickView()
    view.engine().quit.connect(app.quit)
    view.setSource(QUrl("qrc:/demos/calqlatr/calqlatr.qml"))
    if view.status() == QQuickView.Error:
        sys.exit(-1)
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.show()

    sys.exit(app.exec_())
Ejemplo n.º 10
0
def main():
    import os
    import sys

    CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
    os.environ["QTWEBENGINE_DICTIONARIES_PATH"] = os.path.join(
        CURRENT_DIR, "qtwebengine_dictionaries")

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QApplication(sys.argv)

    view = WebView()
    view.setUrl(QUrl("qrc:/index.html"))
    view.resize(500, 640)
    view.show()

    sys.exit(app.exec_())
Ejemplo n.º 11
0
def main():
    import os
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QGuiApplication(sys.argv)

    os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material"

    engine = QQmlApplicationEngine()

    isEmbedded = False

    engine.rootContext().setContextProperty("isEmbedded", isEmbedded)

    engine.load(QUrl("qrc:/qml/main.qml"))

    sys.exit(app.exec_())
Ejemplo n.º 12
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

    app = QApplication(sys.argv)
    url = QUrl()

    if len(sys.argv) > 1:
        url = QUrl.fromUserInput(sys.argv[1])
    else:
        url = QUrl("http://www.google.com/ncr")

    browser = MainWindow(url)
    browser.resize(1024, 768)
    browser.show()

    sys.exit(app.exec_())
Ejemplo n.º 13
0
def main():
    import sys

    QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QCoreApplication.setOrganizationName("QtExamples")

    app = QApplication(sys.argv)

    view = QWebEngineView()

    # set custom page to open all page's links for https scheme in system browser
    view.setPage(WebEnginePage(view))

    profile = view.page().profile()
    popup = NotificationPopup(view)
    profile.setNotificationPresenter(popup.present)

    view.resize(640, 480)
    view.show()
    view.setUrl(QUrl("qrc:/index.html"))
    sys.exit(app.exec_())
Ejemplo n.º 14
0
def main():
    import sys

    QCoreApplication.setOrganizationName("QtExamples")
    QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

    WebUiHandler.registerUrlScheme()

    app = QApplication(sys.argv)

    profile = QWebEngineProfile()
    handler = WebUiHandler()
    profile.installUrlSchemeHandler(WebUiHandler.schemeName, handler)

    page = QWebEnginePage(profile)
    page.load(WebUiHandler.aboutUrl)

    view = QWebEngineView()
    view.setPage(page)
    view.setContextMenuPolicy(Qt.NoContextMenu)
    view.resize(500, 600)
    view.show()

    sys.exit(app.exec_())