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)
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)
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 main(): print("start") app = QApplication(sys.argv) qmlRegisterType(Person, 'People', 1, 0, 'Person') v = QQuickView(QUrl("main.qml")) v.show() sys.exit(app.exec_())
def setup_ui(self): self.view = QQuickView() self.view.setResizeMode(QQuickView.SizeRootObjectToView) container = QWidget.createWindowContainer(self.view) container.setFocusPolicy(Qt.StrongFocus) layout = QVBoxLayout() layout.addWidget(container) self.setLayout(layout) ctx = self.view.rootContext() ctx.setContextProperty("selector", self) ctx.setContextProperty("C", ui_constants) self.set_menu([]) self.set_plan([]) self.set_current(None) self.view.setSource(QUrl(self.path + 'ui.qml')) self.resize(800, 800) self.move(300, 300) self.setWindowTitle('Goal Planner GUI') self.setWindowIcon(QIcon('images/icon.png')) reload = QShortcut(QKeySequence("Ctrl+R"), self) reload.activated.connect(self.reload_ui) quit = QShortcut(QKeySequence("Ctrl+C"), self) quit.activated.connect(self.quit) quit = QShortcut(QKeySequence("Esc"), self) quit.activated.connect(self.quit) self.ros_timer.start(10) self.showMaximized()
def main(): app = QGuiApplication(sys.argv) view = QQuickView() view.setSource(QUrl.fromLocalFile('scene3d.qml')) view.setResizeMode(QQuickView.SizeRootObjectToView) view.show() sys.exit(app.exec_())
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_())
def main(): # start QT UI sargv = sys.argv + ['--style', 'material'] app = QApplication(sargv) font = QFont() font.setFamily("Ariel") app.setFont(font) # manually detect lid open close event from the start ui_view = QQuickView() ui_view.setSource(QUrl.fromLocalFile('RobotPanelSelect.qml')) ui_view.setWidth(800) ui_view.setHeight(480) ui_view.setMaximumHeight(480) ui_view.setMaximumWidth(800) ui_view.setMinimumHeight(480) ui_view.setMinimumWidth(800) # ui_view = UIController.get_ui() ui_view.show() ret = app.exec_() # Teminate sys.exit(ret)
def quickView(url: str, parent=None): view = QQuickView(parent) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl(url)) view.show() return view
def create_main_app(): # create the application main_app = QApplication(sys.argv) # internationalisation # see http://doc.qt.io/qt-5/internationalization.html # see http://pyqt.sourceforge.net/Docs/PyQt5/i18n.html translator = QTranslator() translator.load("arpi/res/i18n/arpi_" + QLocale.system().name()) main_app.installTranslator(translator) # create config global_config = GlobalConfig() # create speech output class global_config.say = Say(global_config) # create quick view view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) # start program AppOverview(view, loaded_apps, global_config).activate() view.show() # clean up main_app.exec_() sys.exit()
def main(): global app # sys.argv.extend(['-platform', 'eglfs']) # Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. app = QApplication(sys.argv) viewer = QQuickView() # The following are needed to make examples run without having to install the module # in desktop environments. extraImportPath = QGuiApplication.applicationDirPath() if sys.platform == 'win32': extraImportPath += "/../../../../qml" else: extraImportPath += "/../../../qml" viewer.engine().addImportPath(extraImportPath) viewer.engine().quit.connect(app.quit) viewer.setTitle("QML Oscilloscope") dataSource = datasource.DataSource(viewer) viewer.rootContext().setContextProperty("dataSource", dataSource) main_qml = path.dirname(__file__) + "/qml/qmloscilloscope/main.qml" viewer.setSource(QUrl(main_qml)) viewer.setResizeMode(QQuickView.SizeRootObjectToView) viewer.setColor(QColor("#404040")) viewer.show() return app.exec_()
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(): # 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()
def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setWindowTitle('Read OpenVSLAM map') self.mapInfo = MapInfo() qml_view = QQuickView() qml_view.rootContext().setContextProperty('mapInfo', self.mapInfo) qml_view.setSource( QUrl( os.path.join(os.path.dirname(os.path.realpath(__file__)), 'read_map.qml'))) qml_view.setResizeMode(QQuickView.SizeRootObjectToView) self.qml_gui = qml_view.rootObject() qml_view_container = QWidget.createWindowContainer(qml_view, self) qml_view_container.setMinimumSize(800, 200) self.setCentralWidget(qml_view_container) self.mapInfo.filenameChanged.connect(self.read_data) self.mapInfo.visualiseCloud.connect(self.pptk) self.mapInfo.visualiseTrajectory.connect(self.pyplot) self.mapInfo.exportCloud.connect(self.export_cloud) self.data = None self.cloud = None self.trajectory = None
def create_qquick_view(script_root, qml_dirs=[], img_providers=[]): view = QQuickView() add_import_paths(view.engine(), qml_dirs) add_image_providers(view.engine(), img_providers) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl.fromLocalFile(script_root)) return view
def test_qquickview(): app = QApplication(sys.argv) view = QQuickView() view.show() sys.exit(app.exec_())
def run(self): # Create main app self.myApp = QApplication(sys.argv) # Create a label and set its properties self.appLabel = QQuickView() #self.appLabel.setSource(QUrl('loading.qml')) # Show the Label self.appLabel.show() # Initialize PhotoBoothEngine. self.pbengine = PhotoBoothEngine() self.pbengine.on_change_url.connect(self.update_url_signal) self.pbengine.on_connect_signal.connect(self.connect_signal) self.pbengine.change_qml(0) self.pbengine.connect_state(0) print("UPDATE") #self.pbengine.on_status.connect(self.appLabel.rootObject().status) #self.pbengine.on_update_filter_preview.connect(self.appLabel.rootObject().updateImageFilterPreview) self.appLabel.rootContext().setContextProperty('pbengine', self.pbengine) self.setup_text_status_fly_component() self.pbengine.start_state_thread(0) # Execute the Application and Exit self.myApp.exec_() sys.exit()
def spawnControlInterface(self, serial_port): if self._control_view is None: self._control_view = QQuickView() self._control_view.engine().rootContext().setContextProperty( "manager", self) self._control_view.setSource( QUrl("plugins/USBPrinting/ControlWindow.qml")) self._control_view.show()
def spawnFirmwareInterface(self, serial_port): if self._firmware_view is None: self._firmware_view = QQuickView() self._firmware_view.engine().rootContext().setContextProperty( "manager", self) self._firmware_view.setSource( QUrl("plugins/USBPrinting/FirmwareUpdateWindow.qml")) self._firmware_view.show()
def run_qml(qmlpath): app = QGuiApplication(sys.argv) qmlRegisterType(QQuickGLItem, 'GLItem', 1, 0, 'GLItem') view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl(qmlpath)) view.show() sys.exit(app.exec_())
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_())
def qt_t1(): app = QGuiApplication([]) view = QQuickView() path = './qml/side3/side3.qml' # 加载的QML文件 view.engine().quit.connect(app.quit) view.setSource(QUrl(path)) view.show() root = view.rootObject() root.updateRotater() # 调用QML函数 app.exec_()
def run_qml(qmlpath): app = QGuiApplication(sys.argv) qmlRegisterType(VideoView, 'PyQt5GLfwTest', 1, 0, 'VideoView') view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl(qmlpath)) view.show() sys.exit(app.exec_())
def main(arguments): app = QGuiApplication(sys.argv) view = QQuickView() f = QFile(':/default.txt') f.open(QIODevice.ReadOnly) model = TreeModel(f.readAll()) f.close() rootContext = view.rootContext().setContextProperty('model', model) view.setSource(QUrl.fromLocalFile('TreeModel.qml')) view.show() sys.exit(app.exec_())
def qml_tutorial(): from PyQt5.QtCore import QUrl from PyQt5.QtQuick import QQuickView app = QApplication([]) url = QUrl('./view.qml') view = QQuickView() view.setSource(url) view.show() sys.exit(app.exec_())
def main(): app = QGuiApplication(sys.argv) dir_path = os.path.dirname(os.path.realpath(__file__)) qmlRegisterType(Hello, 'Hello', 1, 0, 'Hello') view = QQuickView() view.setSource(QUrl(dir_path + "/qml/Main.qml")) view.show() return app.exec_()
def main(): print("start") app = QApplication(sys.argv) qmlRegisterType(Person, 'People', 1, 0, 'Person') v = QQuickView(QUrl("testFindChild.qml")) qmlRoot = v.rootObject() assert isinstance(qmlRoot, QQuickItem) assert isinstance(qmlRoot, QObject) dumpQMLComponents(qmlRoot) result = qmlRoot.findChild(Person, "person") assert result is not None sys.exit(app.exec_())
def __init__(self, parent=None): super(PluginsStore, self).__init__(parent, Qt.Dialog) # QDialog.__init__(self, parent, Qt.Dialog | Qt.FramelessWindowHint) self.setWindowTitle(self.tr("Plugins Store")) self.setMaximumSize(QSize(0, 0)) vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.view = QQuickView() self.view.setMinimumWidth(800) self.view.setMinimumHeight(600) self.view.setResizeMode(QQuickView.SizeRootObjectToView) self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml")) self.root = self.view.rootObject() vbox.addWidget(self.view) self._plugins = {} self._plugins_inflate = [] self._plugins_by_tag = collections.defaultdict(list) self._plugins_by_author = collections.defaultdict(list) self._base_color = QColor("white") self._counter = 0 self._counter_callback = None self._inflating_plugins = [] self._categoryTags = True self._search = [] self.status = None self.connect(self.root, SIGNAL("loadPluginsGrid()"), self._load_by_name) self.connect(self.root, SIGNAL("close()"), self.close) self.connect(self.root, SIGNAL("showPluginDetails(int)"), self.show_plugin_details) self.connect(self.root, SIGNAL("loadTagsGrid()"), self._load_tags_grid) self.connect(self.root, SIGNAL("loadAuthorGrid()"), self._load_author_grid) self.connect(self.root, SIGNAL("search(QString)"), self._load_search_results) self.connect(self.root, SIGNAL("loadPluginsForCategory(QString)"), self._load_plugins_for_category) self.connect(self, SIGNAL("processCompleted(PyQt_PyObject)"), self._process_complete) self.nenv = nenvironment.NenvEggSearcher() self.connect(self.nenv, SIGNAL("searchCompleted(PyQt_PyObject)"), self.callback) self.status = self.nenv.do_search()
def createQuickView(self, transientParent=None): ''' Create empty QQuickView. More robust: connects to error. Subsequently, you should set context and then setSource() ''' result = QQuickView() result.statusChanged.connect(self.onStatusChanged) assert transientParent is not None print("transientParent is:", transientParent, transientParent.isTopLevel()) result.setTransientParent(transientParent) assert result is not None assert isinstance(result, QQuickView) return result
def run_view(self): self._view = QQuickView() self._view.engine().addImportPath("qml") self._rctx = self._view.rootContext() self._view.setResizeMode(QQuickView.SizeRootObjectToView) # set context variables self.categories = [] self._rctx.setContextProperty("categoriesModel", self.categories) self.tiles = [] self.torrents = [] self._rctx.setContextProperty("moviesModel", self.tiles) self._set_loading(False) self._view.setSource(QUrl('qrc:/qml.qml')) self._view.showFullScreen()