Exemple #1
0
def showError(message):
    writeSettings("", "")
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("message", message)
    engine.load(QUrl("qrc:/message.qml"))
    sys.exit(app.exec())
Exemple #2
0
def main():
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()
    controller = MyPersonalViewController()

    schema = [
        QByteArray(str.encode("index")),
        QByteArray(str.encode("dog")),
        QByteArray(str.encode("thirdValue")),
    ]
    michael = Dog("Michael", 23)
    philipp = Dog("Philipp", 18)

    listOfDogs = DogList(schema)
    items = [
        {
            QByteArray(str.encode("index")): "test1",
            QByteArray(str.encode("dog")): michael.name,
            QByteArray(str.encode("thirdValue")): michael.age
        },
        {
            QByteArray(str.encode("index")): "test2",
            QByteArray(str.encode("dog")): philipp.name,
            QByteArray(str.encode("thirdValue")): philipp.age,
        }
    ]
    for item in items:
        listOfDogs.append(item)

    engine.rootContext().setContextProperty("pyModel", listOfDogs)
    engine.rootContext().setContextProperty("controller", controller)
    engine.load(QUrl('view.qml'))
    engine.quit.connect(app.quit)
    sys.exit(app.exec_())
def main() -> None:
    """Application entry point"""
    # configure logging
    logging.basicConfig(level=logging.INFO)

    # create the App ant the event loop
    app = QGuiApplication(sys.argv + ["--style", QUICK_CONTROLS2_STYLE])
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)

    # register custom types
    register_types()

    # create the QML engine
    engine = QQmlApplicationEngine()
    # set context properties
    engine.rootContext().setContextProperty("version", VERSION)
    engine.rootContext().setContextProperty("author", AUTHOR)
    engine.rootContext().setContextProperty("authorEmail", AUTHOR_EMAIL)
    engine.rootContext().setContextProperty("projectUrl", URL)
    # load the main QML file
    engine.load(MAIN_QML_PATH)

    # start the event loop
    with loop:
        loop.run_forever()
Exemple #4
0
    def __init__(self, connections):
        super(QObject, self).__init__()
        self.app = QGuiApplication(sys.argv)
        self.view = QQuickView()
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)
        if settings['alwaysOnTop']:
            self.view.setFlags(Qt.WindowStaysOnTopHint)

        self.con = []
        for connection in connections:
            updaterThread = VVSConnectionUpdater(
                connection[0],
                connection[1],
                connection[2],
                updateDelay=settings['updateDelay'])
            updaterThread.start()
            self.con.append(updaterThread)
            #print(connection)
        #self.con = VVSConnectionUpdater('5006021', 'X60', 'Leonberg Bf')
        #self.con.start()

        #print(self.con)

        self.view.rootContext().setContextProperty('con', self.con)
        self.view.setSource(QUrl(self.QMLFILE))

        #Setup notifications
        VVSNotifier.setup(self.con)
Exemple #5
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 #6
0
def main():
    # Create main app
    myApp = QGuiApplication(sys.argv)
    # myApp.setWindowIcon(QIcon('./images/icon.png'))

    # Create a View and set its properties
    appView = QQuickView()
    appView.setMinimumHeight(640)
    appView.setMinimumWidth(1024)
    appView.setTitle('Authorize Kerberos')

    engine = appView.engine()
    engine.quit.connect(myApp.quit)
    context = engine.rootContext()

    # add paths
    appDir = 'file:///' + QDir.currentPath()
    context.setContextProperty('appDir', appDir)

    # add controllers
    mainController = MainController()
    context.setContextProperty('PyConsole', mainController)
    context.setContextProperty('mainController', mainController)

    # Show the View
    appView.setSource(QUrl('./qml/main.qml'))
    appView.showMaximized()

    # Execute the Application and Exit
    myApp.exec_()
    sys.exit()
Exemple #7
0
def main():
    import sys

    QGuiApplication.setApplicationName("Gallery")
    QGuiApplication.setOrganizationName("QtProject")
    QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

    app = QGuiApplication(sys.argv)

    QIcon.setThemeName("gallery")

    settings = QSettings()

    style = Fakequickcontrols2.name()
    if style:
        settings.setValue("style", style)
    else:
        Fakequickcontrols2.setStyle(settings.value("style"))

    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty(
        "availableStyles", Fakequickcontrols2.availableStyles())
    engine.load(QUrl("qrc:/gallery.qml"))
    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Exemple #8
0
def run():
    app = QGuiApplication([])

    engine = QQmlApplicationEngine()
    qmlRegisterType(MainWindow, 'PyMainWindow', 1, 0, 'MainWindow')
    engine.load(QUrl.fromLocalFile("./gui/main/MainWindow.qml"))
    app.exec_()
Exemple #9
0
def main():
    app = QGuiApplication([])

    try:
        path = QUrl(sys.argv[1])
    except IndexError:
        print("Usage: pyqmlscene <filename>")
        sys.exit(1)

    engine = QQmlApplicationEngine()

    # Procedure similar to
    # https://github.com/qt/qtdeclarative/blob/0e9ab20b6a41bfd40aff63c9d3e686606e51e798/tools/qmlscene/main.cpp
    component = QQmlComponent(engine)
    component.loadUrl(path)
    root_object = component.create()

    if isinstance(root_object, QQuickWindow):
        # Display window object
        root_object.show()
    elif isinstance(root_object, QQuickItem):
        # Display arbitrary QQuickItems by reloading the source since
        # reparenting the existing root object to the view did not have any
        # effect. Neither does the QQuickView class have a setContent() method
        view = QQuickView(path)
        view.show()
    else:
        raise SystemExit("Error displaying {}".format(root_object))

    sys.exit(app.exec_())
Exemple #10
0
def main():
    if os.getuid() != 0:
        print('root permissions needed to launch keylogger')
        return
    no_func_keys = '--no-func-keys' in sys.argv
    if no_func_keys:
        ignored_keys = []
    else:
        ignored_keys = ['<Enter>', '<LShft>', '<#+8>', '<#+18>']

    app = QGuiApplication(sys.argv[:1])

    keypressprovider = KeyPressProvider(ignore_keys=ignored_keys,
                                        no_func_keys=no_func_keys)

    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty("text_provider", keypressprovider)
    engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
    window = engine.rootObjects()[0]
    if not window:
        sys.exit(-1)

    k = keypressprovider.keysPressedChanged

    k.connect(window.setText)
    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)

    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)
Exemple #12
0
    def __init__(self, argv):
        app = QGuiApplication(argv)
        engine = QQmlApplicationEngine()
        context = engine.rootContext()
        context.setContextProperty('mainWindow',
                                   engine)  # the string can be anything

        engine.load('/Users/hebingchang/QtCreator/sniffer/sniffer.qml')
        self.root = engine.rootObjects()[0]
        self.root.setDevModel(pcap.findalldevs())
        self.dev = pcap.findalldevs()[0]
        self.sniffer_status = False

        # self.root.appendPacketModel({'source': '10.162.31.142', 'destination': '151.101.74.49', 'length': 52, 'id': 1})

        self.packetModel = self.root.findChild(QObject, "packetModel")

        btnStart = self.root.findChild(QObject, "btnStart")
        btnStart.clicked.connect(self.myFunction)  # works too

        self.comboDev = self.root.findChild(QObject, "comboDevice")
        self.comboDev.activated.connect(self.getDev)

        engine.quit.connect(app.quit)
        sys.exit(app.exec_())
Exemple #13
0
def main():
    argv = sys.argv

    app = QGuiApplication(argv)

    qmlRegisterType(FigureCanvasQTAggToolbar, "Backend", 1, 0, "FigureToolbar")

    imgProvider = MatplotlibIconProvider()
    view = QQuickView()
    view.engine().addImageProvider("mplIcons", imgProvider)
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(
        QUrl(
            os.path.join(os.path.dirname(__file__), 'backend_qtquick5',
                         'FigureToolbar.qml')))

    win = view.rootObject()
    fig = win.findChild(QObject, "figure").getFigure()
    ax = fig.add_subplot(111)
    x = np.linspace(-5, 5)
    ax.plot(x, np.sin(x))

    view.show()

    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)
def main():
    app = QGuiApplication(sys.argv)
    view = QQuickView()
    view.setSource(QUrl.fromLocalFile('scene3d.qml'))
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.show()
    sys.exit(app.exec_())
Exemple #15
0
def main(argv):
    a = QGuiApplication(argv)

    a.setOrganizationDomain("mapeditor.org")
    a.setApplicationName("TmxRasterizer")
    a.setApplicationVersion("1.0")
    options = CommandLineOptions()
    parseCommandLineArguments(options)
    if (options.showVersion):
        showVersion()
        return 0

    if (options.showHelp or options.fileToOpen == ''
            or options.fileToSave == ''):
        showHelp()
        return 0

    if (options.scale <= 0.0 and options.tileSize <= 0):
        showHelp()
        return 0

    w = TmxRasterizer()
    w.setAntiAliasing(options.useAntiAliasing)
    w.setIgnoreVisibility(options.ignoreVisibility)
    w.setLayersToHide(options.layersToHide)
    if (options.tileSize > 0):
        w.setTileSize(options.tileSize)
    elif (options.scale > 0.0):
        w.setScale(options.scale)

    return w.render(options.fileToOpen, options.fileToSave)
Exemple #16
0
def main():
    app = QGuiApplication(argv)

    qmlRegisterType(Manager.Manager, 'BTManager', 1, 0, 'BTManager')
    qmlRegisterType(Notifier.Notifier, 'BTNotifier', 1, 0, 'BTNotifier')
    qmlRegisterType(Device.Device, 'Device', 1, 0, 'Device')

    print('Create my device')

    notifier = Notifier.Notifier()
    manager = Manager.Manager()
    manager.set_notifier(notifier)

    print('Bluetooth manager create')

    path = os.path.dirname(__file__)
    print('Detect run path')

    print('Run GUI')
    engine = QQmlApplicationEngine()
    engine.rootContext().setContextProperty('AppPath', path)
    engine.rootContext().setContextProperty('MyDevice', manager.my_device)
    engine.rootContext().setContextProperty('BTManager', manager)
    engine.rootContext().setContextProperty('BTNotifier', notifier)
    engine.load('ui/Main.qml')

    print('Start search for near by devices')
    manager.search(True)

    print('Execute app')
    exit(app.exec_())
Exemple #17
0
def main():
    app = QGuiApplication(sys.argv)

    txtInput = TextInputController('michi')

    txtInput.engine.quit.connect(app.quit)
    sys.exit(app.exec_())
Exemple #18
0
    def __init__(self):
        super(QObject, self).__init__()
        self.app = QGuiApplication(sys.argv)
        self.view = QQuickView()
        self.view.setResizeMode(QQuickView.SizeRootObjectToView)
        #self.view.engine().quit.connect(self.app.quit)

        self.cds = CountdownList()
        self.cdt = []
        for name, targetDatetime in {
                "silvester": datetime(2018, 1, 1, 0, 0, 0),
                "geburtstag": datetime(2018, 3, 12, 0, 0, 0)
        }.items():
            cdobj = CountdownData()
            countdown = CountdownTimer(cdobj, targetDatetime, name)
            countdown.start()
            self.cds.append(cdobj)
            self.cdt.append(countdown)

        self.view.rootContext().setContextProperty('countdowns', self.cds)
        self.view.setSource(QUrl(self.QMLFILE))

        self.t = QTimer()
        self.t.timeout.connect(self.addCountdown)
        self.t.start(10000)
 def __init__(self, qml):
   app = QGuiApplication(sys.argv)
   
   model = QmlModel()
   model.register()
   
   qmlUrl=QUrl(qml)
   assert qmlUrl.isValid()
   print(qmlUrl.path())
   #assert qmlUrl.isLocalFile()
   
   """
   Create an engine a reference to the window?
   
   window = QuickWindowFactory().create(qmlUrl=qmlUrl)
   window.show() # visible
   """
   engine = QQmlApplicationEngine()
   '''
   Need this if no stdio, i.e. Android, OSX, iOS.
   OW, qWarnings to stdio.
   engine.warnings.connect(self.errors)
   '''
   engine.load(qmlUrl)
   engine.quit.connect(app.quit)
   
   app.exec_()   # !!! C exec => Python exec_
   print("Application returned")
Exemple #20
0
    def __init__(self, app):
        self.app = app

        #if app.system == 'Windows':
        #    QtCore.QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling)

        self.qt_app = QGuiApplication(sys.argv)
Exemple #21
0
    def __init__(self):
        self.app = QGuiApplication(sys.argv + ['--style', 'material'])

        fontdatabase = QFontDatabase()
        fontdatabase.addApplicationFont("fonts/Exo2-Regular.ttf")
        exo = QFont("Exo 2", 15)
        self.app.setFont(exo)

        self.engine = QQmlApplicationEngine()
        self.bridge = Bridge(self.app, self.engine)

        #responder a KeyboardInterrupt
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        self.engine.rootContext().setContextProperty("bridge", self.bridge)
        self.engine.load("assets/main.qml")

        listDicts = csvInterpreter.readCSV("components.csv")
        for d in listDicts:
            self.bridge.createComponent(d)

        # self.bridge.updateComponents(bytearray.fromhex('5553501408010401080110011F'))

        self.engine.quit.connect(self.app.quit)
        self.app.exec()
Exemple #22
0
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)

    qmlRegisterType(FigureCanvasQTAgg, "Backend", 1, 0, "FigureCanvas")

    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(
        QUrl(
            os.path.join(os.path.dirname(__file__), 'backend_qtquick5',
                         'Figure.qml')))
    view.show()

    win = view.rootObject()
    fig = win.findChild(QObject, "figure").getFigure()
    print(fig)
    ax = fig.add_subplot(111)
    x = np.linspace(-5, 5)
    ax.plot(x, np.sin(x))

    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)
Exemple #23
0
def read(cbz_file):
    qapp = QGuiApplication([])

    reader = CBZReader(cbz_file)

    reader.show()

    qapp.exec_()
Exemple #24
0
 def __init__(self):
     app = QGuiApplication(sys.argv)
     engine = QQmlApplicationEngine()
     handler = Haldler()
     engine.rootContext().setContextProperty("handler", handler)
     engine.load("main.qml")
     engine.quit.connect(app.quit)
     sys.exit(app.exec_())
 def __init__(self, mainqml):
     """mainqml - path to the intitial qml file to be loaded """
     self.app = QGuiApplication(sys.argv)
     self.app.setAttribute(Qt.AA_EnableHighDpiScaling)
     self.engine = QQmlApplicationEngine()
     self._mainqml = mainqml
     self.engine.quit.connect(self.app.quit)
     self.engine.load(self._mainqml)
Exemple #26
0
def main():
    import sys

    app = QGuiApplication(sys.argv)
    w = RasterWindow()
    w.show()

    sys.exit(app.exec_())
Exemple #27
0
    def __init__(self) -> None:
        super().__init__()
        assert Application._instance is None
        Application._instance = self

        PluginRegistry.getInstance().findPlugins(
            os.path.join(os.getcwd(), "plugins"))

        self.__app = QGuiApplication(sys.argv)
        self.__qml_engine = QQmlApplicationEngine(self.__app)
        self.__qml_engine.warnings.connect(self.__onWarning)
        self.__qml_engine.setOutputWarningsToStandardError(False)

        self.__view = View(self)

        qmlRegisterType(MainWindow, "NK3", 1, 0, "MainWindow")
        qmlRegisterType(MouseHandler, "NK3", 1, 0, "MouseHandler")
        qmlRegisterSingletonType(Application, "NK3", 1, 0, "Application",
                                 Application.getInstance)

        self.__process_result = Result()

        self.machine_list = QObjectList[Machine]("machine")

        self.__document_list = QObjectList[DocumentNode]("node")
        self.__document_list.rowsInserted.connect(
            lambda parent, first, last: self.__view.home())

        self.__dispatcher = Dispatcher(self.__document_list)
        self.__dispatcher.onResultData = self.__onResultData
        self.active_machineChanged.connect(self.__onActiveMachineChanged)

        self.__last_file = ""

        s = Storage()
        if s.load():
            s.loadMachines(self.machine_list)
            self.__last_file = s.getGeneralSetting("last_file")
            if os.path.isfile(self.__last_file):
                self._loadFile(self.__last_file)
        if self.machine_list.size() == 0:
            machine_type = PluginRegistry.getInstance().getClass(
                Machine, "RouterMachine")
            assert machine_type is not None
            self.machine_list.append(machine_type())
            output_method_type = PluginRegistry.getInstance().getClass(
                OutputMethod, "GCodeOutputMethod")
            if output_method_type is not None:
                self.machine_list[0].output_method = output_method_type()
            self.machine_list[0].addTool(self.machine_list[0].tool_types[0])
        self.active_machine = self.machine_list[0]

        self.__qml_engine.rootContext().setContextProperty(
            "document_list", self.__document_list)
        self.__qml_engine.load(QUrl("resources/qml/Main.qml"))

        self.__app.aboutToQuit.connect(self._onQuit)
Exemple #28
0
def run():
    app = QGuiApplication([])

    engine = QQmlApplicationEngine()
    qmlRegisterType(model.PersonModel, 'TestModel', 1, 0, 'PersonModel')
    provider = ImageFaceProvider()
    engine.addImageProvider("facesProvider", provider)
    engine.load(QUrl.fromLocalFile("./gui/main/MainWindow.qml"))
    app.exec_()
def main2():
    #app = QtGui.QApplication(sys.argv)
    app = QGuiApplication(sys.argv)

    main = Main()

    main.show()

    sys.exit(app.exec_())
Exemple #30
0
def run_qml(qmlpath):
    app = QGuiApplication(sys.argv)
    register_qml()

    view = QQuickView()
    view.setResizeMode(QQuickView.SizeRootObjectToView)
    view.setSource(QUrl(qmlpath))
    view.show()

    sys.exit(app.exec_())