示例#1
0
 def testIt(self):
     app = QGuiApplication([])
     qmlRegisterType(MyClass, 'Example', 1, 0, 'MyClass')
     view = QQuickView()
     view.setSource(
         QUrl.fromLocalFile(adjust_filename('bug_926.qml', __file__)))
     self.assertEqual(len(view.errors()), 0)
     view.show()
     QTimer.singleShot(0, app.quit)
     app.exec_()
示例#2
0
文件: ui.py 项目: hinki1/dotmatrix
def run(args, field):
    qInstallMessageHandler(msg_handler)

    if "QT_QUICK_CONTROLS_STYLE" not in os.environ:
        os.environ["QT_QUICK_CONTROLS_STYLE"] = "Fusion"

    app = QGuiApplication(args)
    eng = QQmlApplicationEngine()
    eng.rootContext().setContextProperty("field", field)
    eng.load(QUrl("ui.qml"))
    app.exec_()
示例#3
0
def main():
    app = QGuiApplication([])

    # reg qml types here
    register_qml_types()

    # force gc to run
    gc.collect()

    view = QQuickView()
    url = QUrl(__file__.replace(".py", ".qml"))
    view.setSource(url)
示例#4
0
def main(args):
    app = QGuiApplication(args)
    Gst.init(args)

    pipeline = Gst.parse_launch("""videotestsrc ! glupload ! qmlgloverlay name=o ! gldownload ! videoconvert ! autovideosink""")
    o = pipeline.get_by_name('o')
    f = open('overlay.qml', 'r')
    o.set_property('qml-scene', f.read())

    pipeline.set_state(Gst.State.PLAYING)
    app.exec_()
    pipeline.set_state(Gst.State.NULL)
示例#5
0
def run(argv: List[str]):
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    WebEngine.initialize()
    app = QGuiApplication(argv)
    webengine = WebEngine("dodo/" + argv[1], app)
    code = app.exec_()
    # Try to make QtWebEngine to shutdown properly without SIGSEGV
    del webengine
    gc.collect()
    del app
    gc.collect()
    return code
示例#6
0
文件: bug_825.py 项目: zhoub/pyside2
    def testIt(self):
        global paintCalled
        app = QGuiApplication([])
        qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825')
        self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A')

        view = QQuickView()
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(paintCalled)
示例#7
0
文件: main.py 项目: robertvari/TMDB
    def __init__(self):
        self.app = QGuiApplication(sys.argv)
        self.engine = QQmlApplicationEngine()
        self.context = self.engine.rootContext()

        self._setup_context()

        self.engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))

        if not self.engine.rootObjects():
            sys.exit(-1)
        sys.exit(self.app.exec_())
示例#8
0
    def __init__(self):
        self.app = QGuiApplication(sys.argv)

        self.touchscreens = list(filter(lambda d: d.type() == QTouchDevice.TouchScreen, QTouchDevice.devices()))
        if self.touchscreens:
            logger.info("touchscreens detected, disabling mouse: %s" % self.touchscreens)
            # self.app.setOverrideCursor(QCursor(Qt.BlankCursor))
        else:
            logger.error("No touchscreen detected!")

        self.engine = QQmlApplicationEngine()
        self.loop = QEventLoop(self.app)
        asyncio.set_event_loop(self.loop)
示例#9
0
    def __init__(self, city):
        QObject.__init__(self)
        self.app = QGuiApplication()
        self.city = city
        # GET RESULTS FROM API
        self.results_weather = weather.Current_Weather(
            self.city).display_weather_results()

        # AUTO REFRESH / DYNAMIC INFOS
        timer = QTimer(self)
        timer.start(1000)
        timer.timeout.connect(lambda: self.setDynamicInfo())
        self.show_UI()
示例#10
0
def main():
    # sys.argv +=['--style', 'material`']
    QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    app = QGuiApplication(sys.argv)
    speech = Speech()
    settings = Settings()
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty('speech', speech)
    engine.rootContext().setContextProperty('settings', settings)
    engine.load(os.path.join(os.path.dirname(__file__), 'qml/main.qml'))
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
示例#11
0
def main():
    app = QGuiApplication(sys.argv)

    py_tranlator = QTranslator()
    res = py_tranlator.load(os.fspath(TRANSLATIONS_DIR / "py.qm"))
    assert res

    qml_tranlator = QTranslator()
    res = qml_tranlator.load(os.fspath(TRANSLATIONS_DIR / "qml.qm"))
    assert res

    # global_tranlator = QTranslator()
    # res = qml_tranlator.load(os.fspath(TRANSLATIONS_DIR / "global.qm"))
    # assert res

    python_model = PythonModel(app)

    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("pythonModel", python_model)

    filename = os.fspath(QML_DIRECTORY / "main.qml")
    url = QUrl.fromLocalFile(filename)

    def handle_object_created(obj, obj_url):
        if obj is None and url == obj_url:
            QCoreApplication.exit(-1)

    engine.objectCreated.connect(handle_object_created, Qt.QueuedConnection)
    engine.load(url)

    ok = False

    def handle_timeout():
        nonlocal ok
        if ok:
            QCoreApplication.installTranslator(py_tranlator)
            QCoreApplication.installTranslator(qml_tranlator)
            # QCoreApplication.installTranslator(global_tranlator)
        else:
            QCoreApplication.removeTranslator(py_tranlator)
            QCoreApplication.removeTranslator(qml_tranlator)
            # QCoreApplication.removeTranslator(global_tranlator)

        engine.retranslate()

        ok = not ok

    timer = QTimer(interval=1000, timeout=handle_timeout)
    timer.start()

    sys.exit(app.exec_())
示例#12
0
    def testIt(self):
        app = QGuiApplication([])

        qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart')
        qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice")

        view = QQuickView()
        view.setSource(
            QUrl.fromLocalFile(adjust_filename('registertype.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(appendCalled)
        self.assertTrue(paintCalled)
示例#13
0
def main():
    app = QGuiApplication(sys.argv)
    bridge = Bridge()

    #Set up engine and connect to qml
    engine = QQmlApplicationEngine(app)
    engine.rootContext().setContextProperty("bridge", bridge)
    engine.rootContext().setContextProperty("myModel", model)
    engine.load(QUrl('view.qml'))
    if not engine.rootObjects():
        print("Root Objects not found")
        sys.exit(-1)

    sys.exit(app.exec_())
示例#14
0
def main():
    #     new_connection = serial_connection("/dev/ttyUSB0",9600, serial.PARITY_NONE, serial.STOPBITS_ONE, serial.EIGHTBITS, 0)

    app = QGuiApplication(sys.argv)
    backend = backEnd("/dev/ttyUSB0", 9600, serial.PARITY_NONE,
                      serial.STOPBITS_ONE, serial.EIGHTBITS, 0)
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("backEnd", backend)
    engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))

    win = engine.rootObjects()[0]
    #     win.show()

    return app.exec_()
示例#15
0
文件: main.py 项目: gabridc/Asteria
def main():
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    qmlRegisterType(MainWindowPy, 'MainWindowPy', 1, 0, 'MainWindowPy')

    mainWindow = MainWindowPy()

    engine.load(QUrl("main.qml"))

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

    app.exec_()
示例#16
0
def main():
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    manager = Manager()

    ctx = engine.rootContext()
    ctx.setContextProperty("manager", manager)

    engine.load('view.qml')

    win = engine.rootObjects()[0]
    win.show()

    sys.exit(app.exec_())
示例#17
0
def main():
    sys.argv += ['--style', 'material']

    QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
    QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
    QCoreApplication.setAttribute(Qt.AA_UseOpenGLES)

    app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()
    engine.load('Main.qml')

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
def main():
    app = QGuiApplication(sys.argv)
    bridge = Bridge()
    workers = Workers()

    #Set up engine and connect to qml
    engine = QQmlApplicationEngine(app)
    engine.rootContext().setContextProperty("bridge", bridge)
    engine.rootContext().setContextProperty("workers", workers)
    engine.rootContext().setContextProperty("saveData", data_json)
    bridge.engine = engine
    bridge.load_qml()
    if not engine.rootObjects():
        print("Root Objects not found")
        sys.exit(-1)

    sys.exit(app.exec_())
示例#19
0
def main():
    app = QGuiApplication(sys.argv)
    url = QUrl("./QML/main.qml")

    engine = QQmlApplicationEngine()

    gui = GUI(engine)

    context = engine.rootContext()
    context.setContextProperty("ui", gui)

    engine.load(url)

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

    app.exec_()
def main():
    current_path = os.path.abspath(os.path.dirname(__file__))
    qml_file = os.path.join(current_path,
                            os.path.splitext(__file__)[0] + '.qml')

    parser = argparse.ArgumentParser(description='''
        Given a text file containing prompts, this app will choose a random selection
        and ordering of them, display them to be dictated by the user, and record the
        dictation audio and metadata to a `.wav` file and `recorder.tsv` file
        respectively.
    ''')
    parser.add_argument('-p',
                        '--prompts_filename',
                        help='file containing prompts to choose from')
    parser.add_argument(
        '-d',
        '--save_dir',
        default='../dataset/dictation',
        help='where to save .wav & recorder.tsv files (default: %(default)s)')
    parser.add_argument(
        '-c',
        '--prompts_count',
        type=int,
        default=100,
        help='number of prompts to select and display (default: %(default)s)')
    parser.add_argument('-l', '--prompt_len_soft_max', type=int)
    args = parser.parse_args()
    assert args.prompts_filename

    os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.addImportPath(current_path)
    kwargs = {
        k: v
        for k, v in vars(args).items()
        if v is not None and k in 'prompts_count prompt_len_soft_max'.split()
    }
    recorder = Recorder(args.save_dir, args.prompts_filename, **kwargs)
    engine.rootContext().setContextProperty('recorder', recorder)
    engine.load(qml_file)
    recorder.window = engine.rootObjects()[0]

    res = app.exec_()
    sys.exit(res)
示例#21
0
def main():
    app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()

    filename = os.path.join(CURRENT_DIR, "qml", "main.qml")
    url = QUrl.fromLocalFile(filename)

    def handle_object_created(obj, objUrl):
        if not obj and url == objUrl:
            QCoreApplication.exit(-1)

    engine.objectCreated.connect(handle_object_created, Qt.QueuedConnection)

    engine.load(url)

    ret = app.exec_()
    sys.exit(ret)
示例#22
0
def main():
    # REF [site] >> https://doc.qt.io/qtforpython/tutorials/qmlsqlintegration/qmlsqlintegration.html

    logging.basicConfig(filename='./chat.log', level=logging.DEBUG)
    logger = logging.getLogger('logger')

    app = QGuiApplication()

    connectToDatabase(logger)
    sql_conversation_model = SqlConversationModel()

    engine = QQmlApplicationEngine()
    # Export pertinent objects to QML.
    engine.rootContext().setContextProperty(
        'chat_model', sql_conversation_model)  # chat_model is in ./chat.qml.
    engine.load(QUrl('./chat.qml'))

    app.exec_()
示例#23
0
def main():
    app = QGuiApplication(sys.argv)
    qmlRegisterType(Backend, 'PythonBackendLibrary', 1, 0, 'PythonBackend')

    qml_file = 'main.qml'
    current_dir = os.path.dirname(os.path.realpath(__file__))
    filename = os.path.join(current_dir, qml_file)

    backend = Backend()
    engine = QQmlApplicationEngine()
    win = engine.rootContext()
    engine.load(QUrl.fromLocalFile(filename))

    rospy.init_node('rospy_qt_quick')

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
示例#24
0
def main():
    app = QGuiApplication(sys.argv)

    engine = QQmlApplicationEngine()

    translator = Translator(engine, app)

    engine.rootContext().setContextProperty("translator", translator)
    filename = os.fspath(QML_DIRECTORY / "main.qml")
    url = QUrl.fromLocalFile(filename)

    def handle_object_created(obj, obj_url):
        if obj is None and url == obj_url:
            QCoreApplication.exit(-1)

    engine.objectCreated.connect(handle_object_created, Qt.QueuedConnection)
    engine.load(url)

    sys.exit(app.exec_())
示例#25
0
def run():
    """Start Virtual Warehouse application."""
    QGuiApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    app = QGuiApplication(sys.argv)
    app.setOrganizationName("Bretislav Hajek")
    app.setOrganizationDomain("bretahajek.com")
    app.setApplicationName("Virtual Warehouse")
    app.setApplicationVersion(__version__)
    engine = QQmlApplicationEngine()

    controller = ViewController()
    engine.rootContext().setContextProperty("ViewController", controller)
    engine.rootContext().setContextProperty("versionNumber", __version__)

    app.setWindowIcon(QIcon(":/images/icon.png"))
    engine.load(QtCore.QUrl("qrc:/qml/main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
示例#26
0
def main():
    app = QGuiApplication(sys.argv)

    # QtWebEngine.initialize()

    qmlRegisterType(BackEnd, 'io.qml.locals', 1, 0, 'BackEnd')

    engine = QQmlApplicationEngine()

    context = engine.rootContext()

    myVar = {"A": 18, "B": {"C": 74}}

    context.setContextProperty("myVar", myVar)

    qml_file = os.path.join(BASE_DIR, 'view.qml')
    engine.load(QUrl.fromLocalFile(qml_file))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
示例#27
0
def main():
    """
    Entry point into program
    """
    app = QGuiApplication(sys.argv)

    # Register the Backend which can be used in the qml view
    qmlRegisterType(Backend, 'Interface', 1, 0, 'Backend')

    # Create a quickview widget and load the view
    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(QUrl.fromLocalFile('view.qml'))
    view.show()
    res = app.exec_()

    # Deleting the view before it goes out of scope is required to make
    # sure all child QML instances are destroyed in the correct order.
    # Sept 2019 * Not sure if we still need to do this *
    del view
    sys.exit(res)
def main():
    # QApplication.setAttribute( Qt.AA_UseDesktopOpenGL )
    # QSurfaceFormat.setDefaultFormat(utils.defaultFormat(False)) # from vtk 8.2.0
    app = QGuiApplication(sys.argv)
    app.setApplicationName('QtVTK-Py')
    # qmlRegisterType(FboItem, "QmlVTK", 1, 0, "Interactor")
    qmlRegisterType(FboItem, "QtVTK", 1, 0, "VtkFboItem")

    view = QQuickView()  # qml file must begin with Item, not ApplicationWindow
    view.setSource(QUrl.fromLocalFile(abs_path("main.qml")))
    # view.setTitle ("QQuickView Load")
    # view.setResizeMode(QQuickView.SizeRootObjectToView)
    #    view.setFlags(Qt.FramelessWindowHint)
    view.show()
    '''
    In the unlikely event, you will encounter the following problems: the QML window is stuck.

    Please check if you: import pyside2, and use QmlApplicationEngine().load to load only one qml-vtk window(containing qmlRegisterType class) .
    If you have to do this, plus self.createRenderer () to __ init__ function, fboitem class.
    Then it works but an error window, vtkoutputwindow, will be displayed.
    Then try to close the vtkoutputwindow (maybe call the Win32 API findwindow?)

    Recommended solution: import PyQt5 instead of pyside2;
    Or using QQuickView().setSource to load qml window;
    Or load another independent general qml window before load the qml-vtk window.

    '''
    #    engine1 = QQmlApplicationEngine()  # qml file must begin with ApplicationWindow, not Item
    #    engine1.load(os.path.join(os.path.dirname(__file__), "main.qml")) # another independent general qml window

    #    engine = QQmlApplicationEngine()
    #    engine.load(os.path.join(os.path.dirname(__file__), "app.qml"))  # the qml-vtk window
    #    if not engine.rootObjects():
    #        sys.exit(-1)

    sys.exit(app.exec_())
def main():
    argv = sys.argv

    # Trick to set the style / not found how to do it in pythonic way
    argv.extend(["-style", "universal"])
    app = QGuiApplication(argv)

    # why needed now?
    app.setOrganizationName("Some Company")
    app.setOrganizationDomain("somecompany.com")
    app.setApplicationName("Amazing Application")

    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar")
    imgProvider = MatplotlibIconProvider()

    # !! You must specified the QApplication as parent of QQmlApplicationEngine
    # otherwise a segmentation fault is raised when exiting the app
    engine = QQmlApplicationEngine(parent=app)
    engine.addImageProvider("mplIcons", imgProvider)

    context = engine.rootContext()
    data_model = DataSeriesModel()
    context.setContextProperty("dataModel", data_model)
    mainApp = Form(data=data_model)
    context.setContextProperty("draw_mpl", mainApp)

    engine.load(QUrl('main.qml'))

    win = engine.rootObjects()[0]
    mainApp.figure = win.findChild(QObject, "figure").getFigure()

    rc = app.exec_()
    # There is some trouble arising when deleting all the objects here
    # but I have not figure out how to solve the error message.
    # It looks like 'app' is destroyed before some QObject
    sys.exit(rc)
示例#30
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--server_url', dest='server_url')
    parser.add_argument('--collection', dest='collection')
    options = parser.parse_args()

    anki_client = AnkiRestClient(options.server_url, options.collection)

    notes = anki_client.list_all_notes()
    anki_client.delete_note(notes[0].id)
    notes = anki_client.list_all_notes()
    testnote = Note("test", "test2")
    anki_client.add_note(testnote)

    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    note_model = NoteModel(anki_client)
    sorted_note_model = SortFilterNoteModel()
    sorted_note_model.setSourceModel(note_model)
    regular_deck_model = RegularDeckModel(anki_client)
    dynamic_deck_model = DynamicDeckModel(anki_client)
    engine.rootContext().setContextProperty("noteModel", note_model)
    engine.rootContext().setContextProperty("sortedNoteModel",
                                            sorted_note_model)
    engine.rootContext().setContextProperty("regDeckModel", regular_deck_model)
    engine.rootContext().setContextProperty("dynDeckModel", dynamic_deck_model)

    notes = anki_client.list_all_notes()

    qml_file = os.path.join(os.path.dirname(__file__), "MainWindow.qml")
    engine.load(qml_file)

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

    app.exec_()