Exemple #1
0
    def start(self):
        qt_app = QGuiApplication([])
        qt_app.aboutToQuit.connect(self._app.stop)
        qml_engine = QQmlApplicationEngine(qt_app)

        for plugin in self._app._plugin_registry.plugins.values():
            if not hasattr(plugin, "after_qml_engine_created"):
                continue

            plugin.after_qml_engine_created(qml_engine)

        controller = Controller(qml_engine, self._app)
        qml_engine.rootContext().setContextProperty("controller", controller)
        qml_engine.load(str(self._app.base_directory / "ui/qml/main.qml"))

        qt_app.exec_()
Exemple #2
0
def main():
    app = QGuiApplication(sys.argv)
    app.setApplicationName(metadata.get("Name"))

    # QQuickStyle.setStyle("Material")
    QmlEncryptedJSONStorage6.DICTIONARY = {"$apphome": home}

    engine = Paper()
    encryptedStorage = QmlEncryptedJSONStorage6()
    encryptedStorage._key = 26

    engine.rootContext().setContextProperty("encryptedStorage",
                                            encryptedStorage)
    engine.init_ui()

    sys.exit(app.exec_())
Exemple #3
0
def main(argv: List[str]):
    config = Config(Path(argv[1]))

    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    # Instance of the Python object
    backend = Backend(CoreApp(iter_files(Path('.'), config.exceptions), config.root_folder, config.root_category))

    # Expose the Python object to QML
    context = engine.rootContext()
    context.setContextProperty('backend', backend)

    #qmlRegisterType(Test, 'TestTypes', 1, 0, 'Test')

    # Get the path of the current directory, and then add the name
    # of the QML file, to load it.
    qmlFile = join(dirname(__file__), 'qml', 'main.qml')
    engine.load(abspath(qmlFile))

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

    sys.exit(app.exec_())
Exemple #4
0
    def main(self):
        init()
        # Welcome users, and load configurations.
        try:
            _, self._noupdate, self._config = canvas_grab.get_options.get_options(
            )
        except TypeError:
            # User canceled the configuration process
            return

        app = QGuiApplication(sys.argv)
        app.setQuitOnLastWindowClosed(True)
        app.aboutToQuit.connect(self._exit_handler)
        engine = QQmlApplicationEngine()
        engine.rootContext().setContextProperty('py_sync_model', self._model)
        engine.load(os.path.join(os.path.dirname(__file__), "ui/main.qml"))

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

        thread = threading.Thread(target=self._canvas_grab_run)
        thread.start()

        sys.exit(app.exec_())
Exemple #5
0
            self.load_from_json(filename)

    def load_from_json(self,filename):
        """Load list of cities from given file"""
        with open(filename,encoding="utf-8") as f:
            self.city_list = json.load(f)

    def rowCount(self, parent:QtCore.QModelIndex=...) -> int:
        """ Return number of cities in the list"""
        return len(self.city_list)

    def data(self, index:QtCore.QModelIndex, role:int=...) -> typing.Any:
        """ For given index and DisplayRole return name of the selected city"""
        # Return None if the index is not valid
        if not index.isValid():
            return None
        # If the role is the DisplayRole, return name of the city
        if role == QtCore.Qt.DisplayRole:
            return self.city_list[index.row()]["muniLabel"]


app = QGuiApplication(sys.argv)
view = QQuickView()
url = QUrl(VIEW_URL)
citylist_model = CityListModel(CITY_LIST_FILE)
ctxt = view.rootContext()
ctxt.setContextProperty('cityListModel',citylist_model)
view.setSource(url)
view.show()
app.exec_()
Exemple #6
0
    colorChanged = Signal()
    color = Property(QColor, getColor, setColor, notify=colorChanged)
    name = Property(str, getName, setName)
    chartCleared = Signal()

    @Slot()  # This should be something like @Invokable
    def clearChart(self):
        self.setColor(Qt.transparent)
        self.update()
        self.chartCleared.emit()


if __name__ == '__main__':
    app = QGuiApplication(sys.argv)

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

    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    qmlFile = os.path.join(os.path.dirname(__file__), 'app.qml')
    view.setSource(QUrl.fromLocalFile(os.path.abspath(qmlFile)))
    if view.status() == QQuickView.Error:
        sys.exit(-1)
    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.
    del view
    sys.exit(res)
Exemple #7
0
        if (self.staticUser.lower() == getUser.lower()
                and self.staticPass == getPass):
            # Send User And Pass
            self.signalUser.emit("Username: "******"Password: "******"Login passed!")
        else:
            self.signalLogin.emit(False)
            print("Login error!")


# INSTACE CLASS
if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    # Get Context
    main = MainWindow()
    engine.rootContext().setContextProperty("backend", main)

    # Load QML File
    engine.load(os.path.join(os.path.dirname(__file__), "qml/main.qml"))

    # Check Exit App
    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
Exemple #8
0
                if filename[-3:] == 'qml' and 'IN_MODIFY' in type_names:
                    reload = True
                    break

            if reload:
                self.requestReload.emit()


if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    workerThread = QThread()
    workerThread.start()
    worker = Worker()
    worker.moveToThread(workerThread)

    master = Master()
    master.command.connect(worker.run)
    worker.requestReload.connect(master.reload)
    master.command.emit()

    # Stop application gracefully:
    signal.signal(signal.SIGINT, signal.SIG_DFL)
    status = app.exec_()
    worker.stop()
    workerThread.quit()
    workerThread.wait()
    sys.exit(status)