Exemple #1
0
def main():

    app = QCoreApplication(sys.argv)

    server = SslEchoServer(1234)  # noqa: F841

    sys.exit(app.exec_())
Exemple #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_())
Exemple #3
0
 def loadFinished(self, ok: bool):
     if not ok:
         sys.stderr.write("failed to load URL '{}'".format(
             self.m_inputPath))
         QCoreApplication.exit(1)
         return
     self.m_page.printToPdf(self.m_outputPath)
Exemple #4
0
 def pdfPrintingFinished(self, filePath: str, success: bool):
     if not success:
         sys.stderr.write("failed to print to output file '%s'" %
                          (filePath, ))
         QCoreApplication.exit(1)
     else:
         QCoreApplication.quit()
Exemple #5
0
 def retranslateUi(self, Form):
     Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
     self.label.setText(
         QCoreApplication.translate("Form", u"Overall Progress", None))
     self.lapsed_time_label.setText(
         QCoreApplication.translate("Form", u"Lapsed time: 00:00:00", None))
     self.estimated_time_label.setText(
         QCoreApplication.translate("Form",
                                    u"Estimated time remaining: 00:00:00",
                                    None))
Exemple #6
0
def main():
    import sys

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

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

    sys.exit(app.exec_())
Exemple #7
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_())
Exemple #8
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_())
Exemple #9
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_())
Exemple #10
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_())
Exemple #11
0
def commandLineUrlArgument() -> QUrl:
    args = QCoreApplication.arguments()
    for arg in args[1:]:
        if not arg.startswith("_"):
            return QUrl.fromUserInput(arg)

    return QUrl("https://www.qt.io")
Exemple #12
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_())
Exemple #13
0
def main():
    import sys

    app = QCoreApplication(sys.argv)  # noqa: F841
    f = QFile()
    f.open(sys.stdout.fileno(), QIODevice.WriteOnly)
    out = QTextStream(f)
    serialPortInfos = QSerialPortInfo.availablePorts()

    out << "Total number of ports available: " << len(serialPortInfos) << "\n"

    blankString = "N/A"
    description = ""
    manufacturer = ""
    serialNumber = ""

    for serialPortInfo in serialPortInfos:
        description = serialPortInfo.description()
        manufacturer = serialPortInfo.manufacturer()
        serialNumber = serialPortInfo.serialNumber()
        out << "\nPort: " << serialPortInfo.portName(
        ) << "\nLocation: " << serialPortInfo.systemLocation(
        ) << "\nDescription: " << (  # noqa: E501
            description if description else blankString
        ) << "\nManufacturer: " << (
            manufacturer
            if manufacturer else blankString) << "\nSerial number: " << (
                serialNumber if serialNumber else blankString
            ) << "\nVendor Identifier: " << (
                QByteArray.number(serialPortInfo.vendorIdentifier(), 16)
                if serialPortInfo.hasVendorIdentifier() else blankString
            ) << "\nProduct Identifier: " << (
                QByteArray.number(serialPortInfo.productIdentifier(), 16) if
                serialPortInfo.hasProductIdentifier() else blankString) << "\n"
Exemple #14
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_())
Exemple #15
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_())
Exemple #16
0
 def _doit(factory):
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test', False) and is_windows_platform():
         QTimer.singleShot(500, app, Slot('quit()'))
     main_window.show()
     app.exec_()
Exemple #17
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_())
Exemple #18
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_())
Exemple #19
0
 def _doit(factory):
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test', False) and is_windows_platform():
         QTimer.singleShot(500, app, Slot('quit()'))
     main_window.show()
     app.exec_()
Exemple #20
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_())
 def retranslateUi(self, StyleWidget):
     StyleWidget.setWindowTitle(
         QCoreApplication.translate("StyleWidget", u"Form", None))
     self.groupBox.setTitle(
         QCoreApplication.translate("StyleWidget", u"Styles", None))
     self.transparentStyle.setText(
         QCoreApplication.translate("StyleWidget", u"Transp.", None))
     self.blueStyle.setText(
         QCoreApplication.translate("StyleWidget", u"Blue", None))
     self.khakiStyle.setText(
         QCoreApplication.translate("StyleWidget", u"Khaki", None))
     self.noStyle.setText(
         QCoreApplication.translate("StyleWidget", u"None", None))
     self.label.setText(
         QCoreApplication.translate("StyleWidget", u"Value:", None))
     self.pushButton_2.setText(
         QCoreApplication.translate("StyleWidget", u"Show", None))
     self.pushButton.setText(
         QCoreApplication.translate("StyleWidget", u"Enable", None))
     self.close.setText(
         QCoreApplication.translate("StyleWidget", u"Close", None))
Exemple #22
0
        def _func(*args, **kwargs):
            app = QCoreApplication.instance()
            if app is None:
                return func(*args, **kwargs)

            runner = Runner()
            try:
                runner.moveToThread(app.thread())
                app.notify(runner, Event(func, args, kwargs))
                return runner.result.get()
            finally:
                runner.deleteLater()
Exemple #23
0
def main():
    import sys

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

    view = QWebEngineView()
    view.setUrl(QUrl("qrc:/index.html"))
    view.resize(1024, 750)
    view.show()

    handler = PrintHandler()
    handler.setPage(view.page())

    printPreviewShortCut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_P), view)
    printShortCut = QShortcut(QKeySequence(Qt.CTRL + Qt.SHIFT + Qt.Key_P), view)

    printPreviewShortCut.activated.connect(handler.printPreview)
    printShortCut.activated.connect(handler.print)

    sys.exit(app.exec_())
Exemple #24
0
    def download(self):
        """Download Files.   """

        if self.is_downloading:
            return
        self.is_downloading = True
        self.buttonBox.setEnabled(False)

        try:
            is_skip_same = self.checkBoxSkipSame.isChecked()
            pool = Pool()
            for i in progress(self.files, '下载文件', parent=self):
                result = pool.apply_async(i.download,
                                          (Path(self.dir) / Path(i).name, ),
                                          dict(is_skip_same=is_skip_same))
                while not result.ready():
                    QCoreApplication.processEvents()
                if not result.successful():
                    raise RuntimeError('Download failed', i)
        finally:
            self.is_downloading = False
            self.buttonBox.setEnabled(True)
Exemple #25
0
 def _doit(factory):
     # for windows these needs to be repeated due to multiprocessing (?)
     from Qt.QtWidgets import QApplication
     from Qt.QtCore import QCoreApplication
     try:
         app = QApplication([])
     except RuntimeError:
         app = QCoreApplication.instance()
     main_window = factory()
     if getattr(sys, '_called_from_test',
                False) and (is_windows_platform() or is_macos_platform()):
         QTimer.singleShot(1000, app.quit)
     main_window.show()
     app.exec_()
Exemple #26
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_())
Exemple #27
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_())
Exemple #28
0
 def retranslateUi(self, Preferences):
     Preferences.setWindowTitle(
         QCoreApplication.translate("Preferences", u"Hypnotoad Preferences",
                                    None))
     self.defaultGridFileNameLabel.setText(
         QCoreApplication.translate("Preferences",
                                    u"Default grid file name", None))
     self.defaultGridFileNameLineEdit.setPlaceholderText(
         QCoreApplication.translate("Preferences", u"bout.grid.nc", None))
     self.plotXlowLabel.setText(
         QCoreApplication.translate("Preferences", u"Plot xlow", None))
     self.plotYlowLabel.setText(
         QCoreApplication.translate("Preferences", u"Plot ylow", None))
     self.plotCornersLabel.setText(
         QCoreApplication.translate("Preferences", u"Plot corners", None))
     self.saveFullYamlLabel.setText(
         QCoreApplication.translate(
             "Preferences",
             u"Include options set by\ndefault when saving to YAML", None))
 def retranslateUi(self, Hypnotoad):
     Hypnotoad.setWindowTitle(
         QCoreApplication.translate("Hypnotoad", u"MainWindow", None))
     self.action_New.setText(
         QCoreApplication.translate("Hypnotoad", u"&New", None))
     #if QT_CONFIG(shortcut)
     self.action_New.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+N", None))
     #endif // QT_CONFIG(shortcut)
     self.action_Open.setText(
         QCoreApplication.translate("Hypnotoad", u"&Open", None))
     #if QT_CONFIG(shortcut)
     self.action_Open.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+O", None))
     #endif // QT_CONFIG(shortcut)
     self.action_Save.setText(
         QCoreApplication.translate("Hypnotoad", u"&Save", None))
     #if QT_CONFIG(tooltip)
     self.action_Save.setToolTip(
         QCoreApplication.translate("Hypnotoad", u"Save", None))
     #endif // QT_CONFIG(tooltip)
     #if QT_CONFIG(shortcut)
     self.action_Save.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+S", None))
     #endif // QT_CONFIG(shortcut)
     self.action_Save_as.setText(
         QCoreApplication.translate("Hypnotoad", u"Save as", None))
     #if QT_CONFIG(shortcut)
     self.action_Save_as.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+Shift+S", None))
     #endif // QT_CONFIG(shortcut)
     self.action_Quit.setText(
         QCoreApplication.translate("Hypnotoad", u"&Quit", None))
     #if QT_CONFIG(shortcut)
     self.action_Quit.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+Q", None))
     #endif // QT_CONFIG(shortcut)
     self.action_About.setText(
         QCoreApplication.translate("Hypnotoad", u"&About", None))
     self.action_Run.setText(
         QCoreApplication.translate("Hypnotoad", u"&Run", None))
     #if QT_CONFIG(shortcut)
     self.action_Run.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+R", None))
     #endif // QT_CONFIG(shortcut)
     self.action_Write_grid.setText(
         QCoreApplication.translate("Hypnotoad", u"&Write grid", None))
     #if QT_CONFIG(shortcut)
     self.action_Write_grid.setShortcut(
         QCoreApplication.translate("Hypnotoad", u"Ctrl+W", None))
     #endif // QT_CONFIG(shortcut)
     self.action_Revert.setText(
         QCoreApplication.translate("Hypnotoad", u"&Revert", None))
     self.action_Preferences.setText(
         QCoreApplication.translate("Hypnotoad", u"&Preferences...", None))
     self.action_Regrid.setText(
         QCoreApplication.translate("Hypnotoad", u"Re&grid", None))
     self.action_Regrid.setToolTip(
         QCoreApplication.translate("Hypnotoad",
                                    u"Regrid non-orthogonal mesh", None))
     ___qtablewidgetitem = self.options_form.horizontalHeaderItem(0)
     ___qtablewidgetitem.setText(
         QCoreApplication.translate("Hypnotoad", u"Name", None))
     ___qtablewidgetitem1 = self.options_form.horizontalHeaderItem(1)
     ___qtablewidgetitem1.setText(
         QCoreApplication.translate("Hypnotoad", u"Value", None))
     self.options_file_browse_button.setText(
         QCoreApplication.translate("Hypnotoad", u"Browse", None))
     self.geqdsk_file_browse_button.setText(
         QCoreApplication.translate("Hypnotoad", u"Browse", None))
     self.run_button.setText(
         QCoreApplication.translate("Hypnotoad", u"Run", None))
     self.write_grid_button.setText(
         QCoreApplication.translate("Hypnotoad", u"Write Grid", None))
     self.geqdsk_file_label.setText(
         QCoreApplication.translate("Hypnotoad", u"geqdsk file", None))
     self.options_file_label.setText(
         QCoreApplication.translate("Hypnotoad", u"Options file", None))
     self.regrid_button.setToolTip(
         QCoreApplication.translate(
             "Hypnotoad",
             u"Recalculate spacing of non-orthogonal grids (check 'Non-Orthogonal' box to activate)",
             None))
     self.regrid_button.setText(
         QCoreApplication.translate("Hypnotoad", u"Regrid", None))
     self.nonorthogonal_box.setToolTip(
         QCoreApplication.translate(
             "Hypnotoad", u"Check to generate non-orthogonal grids", None))
     self.nonorthogonal_box.setText(
         QCoreApplication.translate("Hypnotoad", u"Non-Orthogonal", None))
     self.menu_File.setTitle(
         QCoreApplication.translate("Hypnotoad", u"&File", None))
     self.menu_Help.setTitle(
         QCoreApplication.translate("Hypnotoad", u"&Help", None))
     self.menu_Mesh.setTitle(
         QCoreApplication.translate("Hypnotoad", u"&Mesh", None))
     self.toolBar.setWindowTitle(
         QCoreApplication.translate("Hypnotoad", u"toolBar", None))
     self.toolBar_2.setWindowTitle(
         QCoreApplication.translate("Hypnotoad", u"toolBar_2", None))
     self.toolBar_3.setWindowTitle(
         QCoreApplication.translate("Hypnotoad", u"toolBar_3", None))
 def start(self):
     self._background_thread.start()
     QCoreApplication.instance().aboutToQuit.connect(self.stop)
Exemple #31
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)