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 __init__(self, settings, windowInfo): QQuickView.__init__(self) self._settings = settings surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.set_cursor_shape("shape_start_cursor") self.setColor(QColor(0, 0, 0, 0)) self.setFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setResizeMode(QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.setTitle(_("Deepin screenshot")) self.qimage = QImage(self._settings.tmpImageFile) self.qpixmap = QPixmap() self.qpixmap.convertFromImage(self.qimage) self.window_info = windowInfo self._grabPointerStatus = False self._grabKeyboardStatus = False self._grabFocusTimer = self._getGrabFocusTimer() self._osdShowed = False self._osdShowing = False self._quitOnOsdTimeout = False
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 __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(): 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 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 test_qquickview(): app = QApplication(sys.argv) view = QQuickView() view.show() sys.exit(app.exec_())
def __init__(self, parent=None): QQuickView.__init__(self, parent) if getattr(sys, "frozen", ""): qml_path = os.path.join(app.executable_dir(), "qml") else: qml_path = os.path.expanduser("~/git/fs-uae/fs-uae-launcher/qml") engine = self.engine() print(engine.importPathList()) print(engine.pluginPathList()) # engine.setPluginPathList([qml_path, "."]) # engine.addPluginPath(qml_path) # engine.addImportPath(qml_path) # engine.setPluginPathList([qml_path, "."]) # engine.setImportPathList([qml_path]) # engine.addPluginPath(qml_path) # print("setImportPathList", [QUrl.fromLocalFile(qml_path)]) self.setSource( QUrl.fromLocalFile( os.path.join(qml_path, "ScaledUserInterface.qml"))) # self.game_center_view = GameCenterView() self.engine().quit.connect(self.on_quit) self.resize(960, 540)
def __init__(self, context): QQuickView.__init__(self) self.context = context self.settings = context.settings surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.set_cursor_shape("shape_start_cursor") self.setColor(QColor(0, 0, 0, 0)) self.setFlags(Qt.X11BypassWindowManagerHint | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) self.setResizeMode(QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.setTitle(_("Deepin Screenshot")) self.qimage = QImage(self.settings.tmpImageFile) self.qpixmap = QPixmap() self.qpixmap.convertFromImage(self.qimage) self.window_info = context.windowInfo self._grabPointerStatus = False self._grabKeyboardStatus = False self._grabFocusTimer = self._getGrabFocusTimer()
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_())
class View(object): def __init__(self, iface, chart): dir_path = os.path.dirname(os.path.realpath(__file__)) qml = os.path.join(dir_path, "qml", "scatterplot.qml") self.view = QQuickView() self.view.setResizeMode(QQuickView.SizeRootObjectToView) self.view.rootContext().setContextProperty("pychart", chart) self.view.setColor(QColor("#000000")) self.view.setSource(QUrl.fromLocalFile(qml)) self.container = QWidget.createWindowContainer(self.view) self.widget = QDockWidget() self.widget.setWidget(self.container) iface.addDockWidget(Qt.BottomDockWidgetArea, self.widget) self.read_settings() def read_settings(self, settings=None): if not settings: settings = Settings.Snapshot() self.view.setColor(QColor(settings.background_color)) def show(self): self.widget.show() def hide(self): self.widget.hide()
def __init__(self): QQuickView.__init__(self) surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.setColor(QColor(0, 0, 0, 0)) self.setFlags( Qt.Tool | Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.X11BypassWindowManagerHint ) self.setResizeMode(QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.set_all_contexts() self.setSource(QUrl.fromLocalFile(os.path.join( ROOT_LOCATION, 'frame', 'views', 'Main.qml'))) self.connect_all_object_function() self.engine_obj = self.engine() connect_to_primary_changed(self.display_primary_changed) self._dbus_adptor = DssDbusAdptor(self) qApp.focusWindowChanged.connect(self.onFocusWindowChanged)
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 __init__(self, parent=None): QQuickView.__init__(self, parent) self.parent = parent self.setSource(QUrl('QML/PreviewWindow.qml')) self.previewContext = CP.ContextPreview(self) self.rootContext().setContextProperty("previewContext", self.previewContext)
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 __init__(self, x, y, menuJsonContent, withCorner): QQuickView.__init__(self) self.__x = x self.__y = y self.__menuJsonContent = menuJsonContent self.__withCorner = withCorner self._cornerDirection = "down"
def __init__(self, mainForm): QQuickView.__init__(self) self.mainForm = mainForm self.setMinimumWidth(600) self.setMinimumHeight(600) self.rootContext().setContextProperty('dbView', self) self.setSource(QUrl("qml/intro.qml")) self.setTitle("Logging") self.show()
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, 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 __init__(self): QQuickView.__init__(self) surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.setColor(QColor(0, 0, 0, 0)) self.setFlags(QtCore.Qt.FramelessWindowHint) self.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.qml_context = self.rootContext()
def add_qml_import_path(self, view: QQuickView) -> None: """ Manually set the path to the QML folder to fix errors with unicode paths. This is needed only on Windows when packaged with Nuitka. """ if Options.freezer != "nuitka": return qml_dir = Options.res_dir.parent / "PyQt5" / "Qt" / "qml" log.debug(f"Setting QML import path for {view} to {qml_dir!r}") view.engine().addImportPath(str(qml_dir))
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 main(): app = QGuiApplication(sys.argv) view = QQuickView() view.setSource(QUrl.fromLocalFile('scene3d.qml')) view.setResizeMode(QQuickView.SizeRootObjectToView) view.show() sys.exit(app.exec_())
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 __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 quickView(url: str, parent=None): view = QQuickView(parent) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl(url)) view.show() return view
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_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()
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 __init__(self, state, app): QtCore.QObject.__init__(self) self.state = state self.app = app # Create the QML user interface. self.login_win = QQuickView() self.login_win.setTitle(self.tr("Xiami Login")) self.login_win.setSource(QUrl('login.qml')) self.login_win.setResizeMode(QQuickView.SizeRootObjectToView) self.login_win.show() # Connect signals self.root_obj = self.login_win.rootObject() self.root_obj.loginClicked.connect(self.login_clicked) self.root_obj.exitClicked.connect(self.exit_clicked)
def __init__(self): QMainWindow.__init__(self) self.setWindowTitle("Qt Combo Demo") widget = QWidget() layout = QVBoxLayout() view = QQuickView() container = QWidget.createWindowContainer(view, self) container.setMinimumSize(200, 200) container.setMaximumSize(200, 200) view.setSource(QUrl("view.qml")) label = QLabel("Hello World") label.setAlignment(Qt.AlignCenter) layout.addWidget(label) layout.addWidget(container) widget.setLayout(layout) self.setCentralWidget(widget)
def __init__(self): self._controller = Controller(self) self._gui = QGuiApplication(sys.argv) self._qml_dir = os.path.dirname(os.path.realpath(__file__)) self._main = QQuickView() self._main.setResizeMode(QQuickView.SizeRootObjectToView) self._main.setSource(QUrl(self._qml_dir + "/main.qml")) self._main.rootObject().create_node.connect(self._controller.create_node) self._main.rootObject().mouse_position.connect(self._controller.mouse_position) self._main.rootObject().save.connect(self._controller.save) self._main.rootObject().load.connect(self._controller.load) self._main.rootObject().lose_focus.connect(self._controller.lose_focus) self._main.rootObject().node_color_sel.connect(self._controller.node_color_sel) self._main.rootObject().edge_color_sel.connect(self._controller.edge_color_sel) self._main.rootObject().workspace_size_changed.connect(self._controller.window_resize) self._main.rootObject().edge_type_sel.connect(self._controller.edge_type_sel) self._main.rootObject().node_shape_sel.connect(self._controller.node_shape_sel) self._main.rootObject().clear_workspace.connect(self._controller.clear_workspace) self._main.rootObject().node_width_changed.connect(self._controller.node_width_changed) self._main.rootObject().node_height_changed.connect(self._controller.node_height_changed) self._main.rootObject().node_text_color_sel.connect(self._controller.node_text_color_sel) self._main.rootObject().node_text_size_changed.connect(self._controller.node_text_size_changed) self._main.rootObject().edge_thickness_changed.connect(self._controller.edge_thickness_changed) self._main.rootObject().show_edge_controls.connect(self._controller.show_edge_controls) self._main.rootObject().hide_edge_controls.connect(self._controller.hide_edge_controls) self._main.rootObject().exporting.connect(self._controller.exporting) self._main.setProperty("width", self._controller.project.workspace_width) self._main.setProperty("height", self._controller.project.workspace_height) self._main.show()
def __init__(self, center=False): QQuickView.__init__(self) self._center_request_count = 1 if center else 0 surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.setColor(QColor(0, 0, 0, 0)) self.setMinimumSize(QSize(MINIMIZE_WIDTH, MINIMIZE_HEIGHT)) self.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.staysOnTop = False self.qml_context = self.rootContext() self.setTitle(_("Deepin Movie")) self.setIcon(icon_from_theme("Deepin", "deepin-movie")) self.setDeepinWindowShadowHint(self.windowGlowRadius)
def __init__(self): QtCore.QObject.__init__(self) self._controller = Controller() self.view = QQuickView() full_path = os.path.realpath(__file__) folder = os.path.dirname(full_path) qml_file = os.path.join(folder, 'qml', 'App.qml') qml_qurl = QtCore.QUrl.fromLocalFile(qml_file) self.view.setSource(qml_qurl) # Add context properties to use this objects from qml rc = self.view.rootContext() rc.setContextProperty('controller', self._controller)
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 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 __init__(self, emacs_xid, init_width, init_height): QQuickView.__init__(self) surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.setColor(QColor(0, 0, 0, 0)) self.setFlags(QtCore.Qt.FramelessWindowHint) self.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.qml_context = self.rootContext() self.emacs_xid = int(emacs_xid) self.emacs_width = int(init_width) self.emacs_height = int(init_height) self.show()
def quickViewForQML(self, qmlFilename, transientParent=None): ''' Create a QQuickView for qmlFilename. More robust: connects to error ''' quickView = QQuickView() quickView.statusChanged.connect(self.onStatusChanged) qurl = resourceMgr.urlToQMLResource(resourceSubpath=qmlFilename) quickView.setSource(qurl) ''' Show() the enclosing QWindow? But this means the window for e.g. the toolbar is visible separately? ''' #quickView.show() print("Created QQuickView for:", qurl.path()) if transientParent is not None: quickView.setTransientParent(transientParent) return quickView
class MainWindow(QtCore.QObject): def __init__(self): QtCore.QObject.__init__(self) self._controller = Controller() self.view = QQuickView() full_path = os.path.realpath(__file__) folder = os.path.dirname(full_path) qml_file = os.path.join(folder, 'qml', 'App.qml') qml_qurl = QtCore.QUrl.fromLocalFile(qml_file) self.view.setSource(qml_qurl) # Add context properties to use this objects from qml rc = self.view.rootContext() rc.setContextProperty('controller', self._controller) def show(self): self.view.show()
def __init__(self, qml_file): QQuickView.__init__(self) surface_format = QSurfaceFormat() surface_format.setAlphaBufferSize(8) self.setColor(QColor(0, 0, 0, 0)) self.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView) self.setFormat(surface_format) self.setFlags(QtCore.Qt.Popup) self.qml_context = self.rootContext() self.init_translate_info() self.qml_context.setContextProperty("translateInfo", self.translate_info) self.qml_context.setContextProperty("windowView", self) self.qml_context.setContextProperty("settingConfig", setting_config) self.qml_context.setContextProperty("qApp", qApp) self.setSource(QtCore.QUrl.fromLocalFile(os.path.join(get_parent_dir(__file__), qml_file)))
def __init__(self, parent=None): QQuickView.__init__(self, parent) if getattr(sys, "frozen", ""): qml_path = os.path.join(app.executable_dir(), "qml") else: qml_path = os.path.expanduser("~/git/fs-uae/fs-uae-launcher/qml") engine = self.engine() print(engine.importPathList()) print(engine.pluginPathList()) # engine.setPluginPathList([qml_path, "."]) # engine.addPluginPath(qml_path) # engine.addImportPath(qml_path) # engine.setPluginPathList([qml_path, "."]) # engine.setImportPathList([qml_path]) # engine.addPluginPath(qml_path) # print("setImportPathList", [QUrl.fromLocalFile(qml_path)]) self.setSource(QUrl.fromLocalFile( os.path.join(qml_path, "ScaledUserInterface.qml")))
def run(): signal.signal(signal.SIGINT, signal.SIG_DFL) app = QGuiApplication(sys.argv) view = QQuickView() view.setTitle('Hot reloading demo') qml_engine = view.rootContext().engine() qml_engine.addImportPath(lib_dir_path) notifier = HotReloadNotifier(demo_dir_path, qml_engine, parent=app) view.rootContext().setContextProperty('hotReloadNotifier', notifier) qml_url = QUrl.fromLocalFile(os.path.join(demo_dir_path, 'Demo.qml')) view.setSource(qml_url) view.show() exit_code = app.exec_() # notifier.stop() # seems like this is not needed sys.exit(exit_code)
def main(): app = QGuiApplication(sys.argv) app.setApplicationName('InfiniteCopy') openDataBase() view = QQuickView() clipboardItemModel = ClipboardItemModel() clipboardItemModel.create() filterProxyModel = QSortFilterProxyModel() filterProxyModel.setSourceModel(clipboardItemModel) clipboard = Clipboard() clipboard.setFormats([ mimeText, mimeHtml, mimePng, mimeSvg ]) clipboard.changed.connect(clipboardItemModel.addItem) engine = view.engine() imageProvider = ClipboardItemModelImageProvider(clipboardItemModel) engine.addImageProvider("items", imageProvider) context = view.rootContext() context.setContextProperty('clipboardItemModel', clipboardItemModel) context.setContextProperty('clipboardItemModelFilterProxy', filterProxyModel) context.setContextProperty('clipboard', clipboard) view.setSource(QUrl.fromLocalFile('qml/MainWindow.qml')) view.setGeometry(100, 100, 400, 240) view.show() engine.quit.connect(QGuiApplication.quit) return app.exec_()
def run_app(): app = QGuiApplication(sys.argv) app.setApplicationName("Worship Prototype") view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__), 'main.qml'))) view.show() root = view.rootObject() preview = DefaultScreen() preview.wire_to_gui(root, 'previewScreen') preview.show_background(VideoBackground(os.path.join(os.path.dirname(__file__), '../echo.mp4'))) # preview_live = DefaultScreen() # live = DefaultScreen() modules = [ LyricsModule(SongsList(), root, preview), ] sys.exit(app.exec_())
def __init__(self): super(QmlStartPage, self).__init__() box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) # View view = QQuickView() view.setSource(QUrl.fromLocalFile(PATH_QML)) view.setResizeMode(QQuickView.SizeRootObjectToView) # Root object self._root = view.rootObject() widget_container = QWidget.createWindowContainer(view) box.addWidget(widget_container) self._root.animationFinished.connect(self._on_animation_finished)
def main(): app = QApplication(sys.argv) # Register the Python type. # qmlRegisterType(Hal.Component, 'Hal', 1, 0, 'Component') # qmlRegisterType(Hal.Pin, 'Hal', 1, 0, 'Pin') qmlRegisterType(Stat.Stat, 'LinuxCNC', 1, 0, 'Stat') qmlRegisterType(Axis.Axis, 'LinuxCNC', 1, 0, 'Axis') qmlRegisterType(Command.Command, 'LinuxCNC', 1, 0, 'Command') qmlRegisterType(ErrorChannel.ErrorChannel, 'LinuxCNC', 1, 0, 'ErrorChannel') quickview = QQuickView() quickview.setSource(QUrl('gui/qml/main.qml')) quickview.showFullScreen() quickview.engine().quit.connect(app.quit) app.exec_()
def __init__(self, argv): QGuiApplication.__init__(self, argv) self.view = QQuickView() self.bus = QDBusConnection.sessionBus() self.server = MyDBUSServer(self) self.bus.registerObject("/app", self.server) self.bus.registerService("sevanteri.TabletShortcuts") self.view.setTitle("TabletShortcuts") self.view.setResizeMode(QQuickView.SizeRootObjectToView) self.view.setSource(QUrl('main.qml')) self.root = self.view.rootObject() self.showView() self.root.runCommand.connect(self.run) self.root.hideView.connect(self.view.hide) self.view.engine().quit.connect(self.quit)
def __init__(self): super(StartPage, self).__init__() vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) view = QQuickView() qml = os.path.join(settings.QML_PATH, "StartPage.qml") view.setSource(QUrl.fromLocalFile(qml)) view.setResizeMode(QQuickView.SizeRootObjectToView) widget = QWidget.createWindowContainer(view) vbox.addWidget(widget) self.__root = view.rootObject() # Connections self.__root.openDatabase.connect(self.__open_database) self.__root.newDatabase.connect(self.__new_database) self.__root.removeCurrent.connect(self.__remove_current)
def __init__(self, parent=None): super(MessageError, self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint) self._parent = parent self.setModal(True) self.setFixedHeight(150) self.setFixedWidth(350) box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) view = QQuickView() qml = os.path.join(settings.QML_PATH, "MessageError.qml") view.setSource(QUrl.fromLocalFile(qml)) view.setResizeMode(QQuickView.SizeRootObjectToView) self.widget = QWidget.createWindowContainer(view) box.addWidget(self.widget) self._root = view.rootObject() self._root.close.connect(self.close)
## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ## $QT_END_LICENSE$ ## ############################################################################# import sys import os.path from PyQt5.QtCore import QUrl from PyQt5.QtGui import QGuiApplication from PyQt5.QtQuick import QQuickView #animation 폴더의 animation_rc 와 shared 폴더의 shared_rc를 import해온다. from shared_rc import * from animation_rc import * if len(sys.argv) is 2:# 실행 옵션으로 파이썬도움말 절대경로 제공시 os.chdir(sys.argv[1]) app = QGuiApplication(sys.argv) view = QQuickView() view.engine().quit.connect(app.quit) view.setSource(QUrl('animation.qml')) view.show() sys.exit(app.exec_())
#!/usr/bin/env python3 import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView # Main Function if __name__ == '__main__': # Create main app myApp = QApplication(sys.argv) # Create a label and set its properties appLabel = QQuickView() appLabel.setSource(QUrl('2.qml')) # Show the Label appLabel.show() # Execute the Application and Exit myApp.exec_() sys.exit()
@pyqtSlot() def sync(self): if not self.m_renderer: print("sync<----------------") self.m_renderer = SquircleRenderer() # self.window()) self.window().beforeRendering.connect(self.m_renderer.paint, Qt.DirectConnection) self.m_renderer.setViewportSize(self.window().size() * self.window().devicePixelRatio()) self.m_renderer.setT(self._t) self.m_renderer.setWin(self.window()) # @pyqtSlot(QQuickWindow) def handleWindowChanged(self, win): if win: win.beforeSynchronizing.connect(self.sync, Qt.DirectConnection) win.sceneGraphInvalidated.connect(self.cleanup, Qt.DirectConnection) win.setClearBeforeRendering(False) if __name__ == "__main__": app = QApplication(sys.argv) qmlRegisterType(Squircle, "OpenGLUnderQML", 1, 0, "Squircle") viewer = QQuickView(QUrl.fromLocalFile("main.qml")) viewer.show() sys.exit(app.exec_())
return animal.type() if role == self.SizeRole: return animal.size() return QVariant() def roleNames(self): return self._roles if __name__ == '__main__': import sys app = QGuiApplication(sys.argv) model = AnimalModel() model.addAnimal(Animal("Wolf", "Medium")) model.addAnimal(Animal("Polar bear", "Large")) model.addAnimal(Animal("Quoll", "Small")) view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) ctxt = view.rootContext() ctxt.setContextProperty('myModel', model) view.setSource(QUrl('qrc:view.qml')) view.show() sys.exit(app.exec_())
import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView from PyQt5.QtQml import QQmlComponent, QQmlEngine from engine import PhotoBoothEngine # Main Function if __name__ == '__main__': # Create main app myApp = QApplication(sys.argv) # Create a label and set its properties appLabel = QQuickView() appLabel.setSource(QUrl('main.qml')) #appLabel.load(QUrl('main2.qml')) # Show the Label appLabel.show() # Create a QML engine. engine = QQmlEngine() # Initialize PhotoBoothEngine. pbengine = PhotoBoothEngine() pbengine.on_status.connect(appLabel.rootObject().status) pbengine.on_update_filter_preview.connect(appLabel.rootObject().updateImageFilterPreview) appLabel.rootContext().setContextProperty('pbengine', pbengine)
class LoginWin(QtCore.QObject): def __init__(self, state, app): QtCore.QObject.__init__(self) self.state = state self.app = app # Create the QML user interface. self.login_win = QQuickView() self.login_win.setTitle(self.tr("Xiami Login")) self.login_win.setSource(QUrl('login.qml')) self.login_win.setResizeMode(QQuickView.SizeRootObjectToView) self.login_win.show() # Connect signals self.root_obj = self.login_win.rootObject() self.root_obj.loginClicked.connect(self.login_clicked) self.root_obj.exitClicked.connect(self.exit_clicked) def set_state(self, msg): self.root_obj.setStatus(msg) def exit_clicked(self): sys.exit(0) def login_clicked(self, username, password): code = self.root_obj.getVerificationCode() if code != "": try: login.login_with_code(self.state, self.key, code) except Exception as e: self.set_state(e.message) self.root_obj.hideCode() return self.ok() else: try: ret = login.login(self.state, username, password) except Exception as e: self.set_state(e.message) return if not ret[0]: with open(login.img_path, 'wb') as imgf: imgf.write(ret[2]) self.set_state(self.tr("Please enter verification code")) self.root_obj.setVerificationImage("file://%s" % login.img_path) self.key = ret[1] else: self.ok() def ok(self): self.login_win.close() self.app.auth_ok()