def _onEngineCreated(self): qmlRegisterType( MaterialSettingsPluginVisibilityHandler. MaterialSettingsPluginVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler") # Adding/removing pages from the preferences dialog is handles in QML # There is no way to access the preferences dialog directly, so we have to search for it preferencesDialog = None for child in CuraApplication.getInstance().getMainWindow().contentItem( ).children(): try: test = child.setPage # only PreferencesDialog has a setPage function preferencesDialog = child break except: pass if preferencesDialog: Logger.log( "d", "Replacing Materials preferencepane with patched version") materialPreferences = QUrl.fromLocalFile( os.path.join(os.path.dirname(os.path.abspath(__file__)), "qml", "MaterialPreferences", "MaterialsPage.qml")) preferencesDialog.removePage(3) preferencesDialog.insertPage( 3, catalog.i18nc("@title:tab", "Materials"), materialPreferences.toString()) else: Logger.log( "e", "Could not replace Materials preferencepane with patched version" )
def register(app): qmlRegisterType(BoundaryConditionList.BoundaryConditionListModel, "SmartSlice", 1, 0, "BoundaryConditionListModel") directory = os.path.dirname(os.path.abspath(__file__)) qmlRegisterType(ResultTable.ResultTableData, "SmartSlice", 1, 0, "ResultsTableModel") qmlRegisterType( QUrl.fromLocalFile( os.path.join(directory, "stage", "ui", "ResultsTable.qml")), "SmartSlice", 1, 0, "ResultsTable") qmlRegisterType( QUrl.fromLocalFile( os.path.join(directory, "select_tool", "BoundaryConditionList.qml")), "SmartSlice", 1, 0, "BoundaryConditionList") qmlRegisterType( QUrl.fromLocalFile( os.path.join(directory, "stage", "ui", "SmartSliceLogin.qml")), "SmartSlice", 1, 0, "SmartSliceLogin") return { "extension": extension, "stage": _stage, "tool": [ requirements_tool, select_tool, ], "view": SmartSliceView.SmartSliceView() }
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)
def __init__(self, loglevel='WARNING', app=None): self.logger = Logger(name='ratt.personality') self.logger.setLogLevelStr(loglevel) PersonalityStateMachine.__init__(self, logger=self.logger) self.logger.info('Personality is ' + self.descr()) self.debug = self.logger.isDebug() if app is None: self.logger.error('must set app to QQmlApplicationEngine object') exit(-1) self.app = app # holds the currently active member record after RFID scan and ACL lookup self.activeMemberRecord = MemberRecord() # expose the active member record to QML self.app.rootContext().setContextProperty("activeMemberRecord", self.activeMemberRecord) qmlRegisterType(MemberRecord, 'RATT', 1, 0, 'MemberRecord') self.app.rfid.tagScan.connect(self.__slotTagScan) self.telemetryEvent.connect(self.app.telemetry.logEvent) self.__init_gpio()
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 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 register(self): # uri = "org.qtproject.demo.weather" ''' Register Python types. - URI is 'People' (i.e. library or module e.g. 'import People 1.0' in QML - it's v1.0 - type will be called 'Person' in QML. ''' # C++ qmlRegisterSingletonType(uri, 1, 0, "ApplicationInfo", systeminfo_provider) # Python signature: qmlRegisterSingletonType(type, str, int, int, str, callable) #qmlRegisterSingletonType("ApplicationInfo", 1, 0, "ApplicationInfo") ''' Unlike c++, where you cast result to a type, in Python first arg is type ''' qmlRegisterType(QmlDelegate, 'QmlDelegate', 1, 0, 'DialogDelegate') ''' BaseResettableValue is a type which QML interacts with, but need not know (be registered.) In this design, a Formation is set in the QML context, and QML calls model (Formation.selectResettableValueByStringSelector('Any.Line.Pen.Color') to get an instance of this type, used as a model for individual style property controls. ''' #qmlRegisterType(BaseResettableValue, 'ResettableValue', 1, 0, 'ResettableValue')
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 __init__(self, ads_client, parent=None): super().__init__(parent) self.application_name = "Plc UiX" # Register the types qmlRegisterType(FilterModel, "FilterModel", 1, 0, "FilterModel") qmlRegisterType(TreeModel, "TreeModel", 1, 0, "TreeModel") # ads_client = AdsClient(args.ams_net_id, args.ams_net_port, lnp_client) self.ads_client = ads_client self.entries = self.ads_client.get_ads_entries() # Append some test entries when no no entries are received if len(self.entries) == 0: self.entries.append( AdsClient.VariableDescriptionEntry("Alpha.alpha", "BOOL", "This is a comment", 1, 1)) self.entries.append( AdsClient.VariableDescriptionEntry("Alpha.beta", "BOOL", "This is also a comment", 1, 1)) self.tree_model = TreeModel() self.tree_model.populate(self.entries) self.filter_model = FilterModel() self.filter_model.setSourceModel(self.tree_model) self.filterModelChanged.emit()
def registerObjects(self, engine): engine.rootContext().setContextProperty("Printer", self) engine.rootContext().setContextProperty("CuraApplication", self) self._print_information = PrintInformation.PrintInformation() engine.rootContext().setContextProperty("PrintInformation", self._print_information) self._cura_actions = CuraActions.CuraActions(self) engine.rootContext().setContextProperty("CuraActions", self._cura_actions) qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type") qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel") qmlRegisterType(cura.Settings.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel") qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler") qmlRegisterType(cura.Settings.QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel") qmlRegisterSingletonType(cura.Settings.ContainerManager, "Cura", 1, 0, "ContainerManager", cura.Settings.ContainerManager.createContainerManager) qmlRegisterSingletonType(QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml")), "Cura", 1, 0, "Actions") engine.rootContext().setContextProperty("ExtruderManager", cura.Settings.ExtruderManager.getInstance()) for path in Resources.getAllResourcesOfType(CuraApplication.ResourceTypes.QmlFiles): type_name = os.path.splitext(os.path.basename(path))[0] if type_name in ("Cura", "Actions"): continue qmlRegisterType(QUrl.fromLocalFile(path), "Cura", 1, 0, type_name)
def runApplication(config): app = QApplication([sys.argv[0]]) desktop = QApplication.desktop() listScreens(desktop) (view, context) = createWindow() header = Header() context.setContextProperty('smoverlay', header) context.setContextProperty('view', view) #if "gui" not in config: old = config.setdefault("gui", {}) config["gui"] = UIConfig.defaultConfig(desktop) config["gui"].update(old) ui = UIConfig(config["gui"]) ui.setGeometry(desktop) context.setContextProperty('ui', ui) monitors = OrderedDict() for plugin in config["plugins"]: for name, data in plugin.items(): m = qmonitors[data["plugin"]]() m.loadConfig(data["config"]) monitors[name] = m types = [UIConfig, UIStyle] for monitor in monitors.values(): types += monitor.types() print("types registered: ", types) for typ in types: qmlRegisterType(typ, "lol", 1, 0, typ.__name__) # FIXME: preloading values for i in range(5): for mon in monitors.values(): mon.update() monitorList = [v for k, v in monitors.items()] context.setContextProperty("monitors", monitorList) qmlpath = "gui/qml/main.qml" if not os.path.exists(qmlpath): qmlpath = "smoverlay/" + qmlpath view.setSource(QUrl.fromLocalFile(qmlpath)) view.setResizeMode(QQuickView.SizeRootObjectToView) #view.rootObject().window().move(desktop.screenGeometry(1).topLeft()) #view.rootObject.setScreen(t #view.setScreen(QApplication.screens()[1]) #view.openglContext().setScreen(QApplication.screens()[1]) view.engine().quit.connect(QApplication.quit) view.show() return app.exec()
def register(app): qmlRegisterType(NetworkMJPGImage.NetworkMJPGImage, "MKSPlugin", 1, 0, "NetworkMJPGImage") return { "output_device": MKSOutputDevicePlugin.MKSOutputDevicePlugin(), "machine_action": MachineConfig.MachineConfig() }
def registerQmlTypes(): directory = os.path.dirname(os.path.abspath(__file__)) qmlRegisterType(ShellInterface, "PythonConsole", 1, 0, "ShellInterface") qmlRegisterType(QUrl.fromLocalFile(os.path.join(directory, "Shell.qml")), "PythonConsole", 1, 0, "Shell")
def run(): app = QGuiApplication([]) engine = QQmlApplicationEngine() qmlRegisterType(MainWindow, 'PyMainWindow', 1, 0, 'MainWindow') engine.load(QUrl.fromLocalFile("./gui/main/MainWindow.qml")) app.exec_()
def register(app): qmlRegisterType(CustomStackProxy.CustomStackProxy, "MaterialSettingsPlugin", 1, 0, "CustomStack") qmlRegisterType( MaterialSettingDefinitionsModel.MaterialSettingDefinitionsModel, "MaterialSettingsPlugin", 1, 0, "MaterialSettingDefinitionsModel") return {"extension": MaterialSettingsPlugin.MaterialSettingsPlugin()}
def dynamic_register(class_name, klass=QQuickItem): if isinstance(class_name, (list, tuple)): for individual in class_name: dynamic_register(individual, klass) else: Component = type(class_name, (klass, ), {}) qmlRegisterType(Component, 'Snowman', 1, 0, class_name) dynamic_components.append(Component)
def register(app): qmlRegisterType(NetworkMJPGImage.NetworkMJPGImage, "RepetierIntegration", 1, 0, "NetworkMJPGImage") return { "output_device": RepetierOutputDevicePlugin.RepetierOutputDevicePlugin(), "machine_action": DiscoverRepetierAction.DiscoverRepetierAction() }
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 __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)
def register(app): qmlRegisterType(NetworkMJPGImage.NetworkMJPGImage, "OctoPrintPlugin", 1, 0, "NetworkMJPGImage") return { "output_device": OctoPrintOutputDevicePlugin.OctoPrintOutputDevicePlugin(), "machine_action": DiscoverOctoPrintAction.DiscoverOctoPrintAction() }
def _initialise_qml_engine(self): super()._initialise_qml_engine() qmlRegisterType(QmlDocument, 'Local', 1, 0, 'Document') context = self.qml_context self._qml_search_manager = QmlSearchManager(self) context.setContextProperty('search_manager', self._qml_search_manager)
def __init__(self, title, args, parser): QApplication.__init__(self, args) qmlRegisterType(RadialBar, "SDK", 1, 0, "RadialBar") self._qquickview = _QQuickView() self._qquickview.setTitle(title) parsed_args = parser.parse_args() self._rfid_card = parsed_args.rfid_card # Debug only so the app can work without a RFID card reader self._engine = self._qquickview.engine()
def register_types() -> None: """Register custom QML types""" qmlRegisterType(ConversationModel, "ChatDemo", 1, 0, "Conversation") qmlRegisterType(ChatService, "ChatService", 1, 0, "ChatService") qmlRegisterUncreatableType(ChannelsModel, "ChannelsModel", 1, 0, "ChannelsModel", "ChannelsModel can't be created in QML!") qmlRegisterUncreatableType(ConversationModel, "ConversationModel", 1, 0, "ConversationModel", "ConversationModel can't be created in QML!")
def main(): app = QGuiApplication(sys.argv) qmlRegisterType(MainController, 'MainController', 1, 0, 'MainController') qmlRegisterType(ProfileViewModel, 'ProfileViewModel', 1, 0, 'ProfileViewModel') engine = QQmlApplicationEngine() main_controller = MainController() main_controller.profile_selection_changed(0) engine.rootContext().setContextProperty('mainController', main_controller) engine.load(QUrl.fromLocalFile(pkg_resources.resource_filename('yarg.resource', 'main.qml'))) 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 register(app): qmlRegisterType(NetworkMJPGImage.NetworkMJPGImage, "OctoPrintPlugin", 1, 0, "NetworkMJPGImage") if __matchVersion(): return { "output_device": OctoPrintOutputDevicePlugin.OctoPrintOutputDevicePlugin(), "machine_action": DiscoverOctoPrintAction.DiscoverOctoPrintAction() } else: Logger.log("w", "Plugin not loaded because of a version mismatch") return {}
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 register(app): if __matchVersion(): qmlRegisterType(NetworkMJPGImage.NetworkMJPGImage, "MKSPlugin", 1, 0, "NetworkMJPGImage") return { "output_device": MKSOutputDevicePlugin.MKSOutputDevicePlugin(), "machine_action": MachineConfig.MachineConfig() } else: Logger.log("w", "Plugin not loaded because of a version mismatch") return {}
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(): app = QGuiApplication(sys.argv) qmlRegisterType(MainController, 'MainController', 1, 0, 'MainController') qmlRegisterType(ProfileViewModel, 'ProfileViewModel', 1, 0, 'ProfileViewModel') engine = QQmlApplicationEngine() main_controller = MainController() main_controller.profile_selection_changed(0) engine.rootContext().setContextProperty('mainController', main_controller) engine.load(QUrl.fromLocalFile('yarg/resource/main.qml')) window = engine.rootObjects()[0] sys.exit(app.exec_())
def _get_application( self, console: bool = False ) -> Union["Application", "ConsoleApplication"]: if console: from .console import ConsoleApplication as Application # noqa else: from .gui.application import Application # noqa from .gui.systray import SystrayWindow from PyQt5.QtQml import qmlRegisterType qmlRegisterType(SystrayWindow, "SystrayWindow", 1, 0, "SystrayWindow") return Application(self.manager)
def main(argv=None): if not argv: argv = sys.argv app = QApplication(argv) # register own type qmlRegisterType(QmlController, 'QmlController', 1, 0, 'QmlController') engine = QQmlApplicationEngine(app) engine.load(QUrl('main.qml')) return app.exec_()
def register(app): qmlRegisterType(NetworkMJPGImage.NetworkMJPGImage, "RepetierIntegration", 1, 0, "NetworkMJPGImage") if __matchVersion(): return { "output_device": RepetierOutputDevicePlugin.RepetierOutputDevicePlugin(), "machine_action": DiscoverRepetierAction.DiscoverRepetierAction() } else: Logger.log("w", "Plugin not loaded because of a version mismatch") return {}
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 registerObjects(self, engine): engine.rootContext().setContextProperty("Printer", self) self._print_information = PrintInformation.PrintInformation() engine.rootContext().setContextProperty("PrintInformation", self._print_information) self._cura_actions = CuraActions.CuraActions(self) engine.rootContext().setContextProperty("CuraActions", self._cura_actions) qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type") qmlRegisterSingletonType(QUrl.fromLocalFile(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml")), "Cura", 1, 0, "Actions") for path in Resources.getAllResourcesOfType(CuraApplication.ResourceTypes.QmlFiles): type_name = os.path.splitext(os.path.basename(path))[0] if type_name in ("Cura", "Actions"): continue qmlRegisterType(QUrl.fromLocalFile(path), "Cura", 1, 0, type_name)
def register(self): uri = "org.qtproject.demo.weather" ''' Register the Python type. - URI is 'People' (i.e. library or module e.g. 'import People 1.0' in QML - it's v1.0 - type will be called 'Person' in QML. ''' # C++ qmlRegisterSingletonType(uri, 1, 0, "ApplicationInfo", systeminfo_provider) # Python signature: qmlRegisterSingletonType(type, str, int, int, str, callable) #qmlRegisterSingletonType("ApplicationInfo", 1, 0, "ApplicationInfo") ''' Unlike c++, where you cast result to a type, in Python first arg is type ''' qmlRegisterType(Person, 'People', 1, 0, 'Person') qmlRegisterType(QmlDelegate, 'QmlDelegate', 1, 0, 'DialogDelegate') qmlRegisterType(Clan, 'Clan', 1, 0, 'Clan') qmlRegisterType(SlottedModel, 'SlottedModel', 1, 0, 'SlottedModel')
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_()
return self._name @name.setter def name(self, name): self._name = name def __init__(self, parent=None): super(PieChart, self).__init__(parent) self._name = '' if __name__ == '__main__': import os import sys app = QGuiApplication(sys.argv) qmlRegisterType(PieChart, "Charts", 1, 0, "PieChart") qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") view = QQuickView() view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource( QUrl.fromLocalFile( os.path.join(os.path.dirname(os.path.abspath(__file__)), 'app.qml'))) view.show() sys.exit(app.exec_())
class ConsoleOutput(QObject): def __init__(self, parent=None): super(ConsoleOutput, self).__init__(parent) @pyqtSlot(str) def out(self, obj): print(obj) if __name__ == '__main__': import sys from Curves import BezierCurve from Generators import JsonGenerator app = QGuiApplication(sys.argv) qmlRegisterType(ConsoleOutput, 'PyConsole', 1, 0, 'PyConsole') qmlRegisterType(BezierCurve, 'Curves', 1, 0, 'BezierCurve') qmlRegisterType(JsonGenerator, 'Generators', 1, 0, 'JsonGenerator') view = QQuickView() context = view.rootContext() view.engine().quit.connect(app.quit) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource( QUrl.fromLocalFile('../view/visionai.qml') ) view.show() for error in view.errors(): print(error.toString())
def register(app): qmlRegisterType(PerObjectSettingVisibilityHandler.PerObjectSettingVisibilityHandler, "Cura", 1, 0, "PerObjectSettingVisibilityHandler") return { "tool": PerObjectSettingsTool.PerObjectSettingsTool() }
def register(self): qmlRegisterType(MainWindow, "UM", 1, 0, "MainWindow") qmlRegisterType(ViewModel, "UM", 1, 0, "ViewModel") #qmlRegisterType(FileModel, "UM", 1, 0, "FileModel") qmlRegisterType(ToolModel, "UM", 1, 0, "ToolModel") qmlRegisterType(JobsModel.JobsModel, "UM", 1, 0, "JobsModel") qmlRegisterType(SettingCategoriesModel.SettingCategoriesModel, "UM", 1, 0, "SettingCategoriesModel") qmlRegisterType(AngledCornerRectangle.AngledCornerRectangle, "UM", 1, 0, "AngledCornerRectangle") # Singleton proxy objects qmlRegisterSingletonType(ControllerProxy, "UM", 1, 0, "Controller", Bindings.createControllerProxy) qmlRegisterSingletonType(ApplicationProxy, "UM", 1, 0, "Application", Bindings.createApplicationProxy) qmlRegisterSingletonType(BackendProxy, "UM", 1, 0, "Backend", Bindings.createBackendProxy) qmlRegisterSingletonType(SceneProxy, "UM", 1, 0, "Scene", Bindings.createSceneProxy) qmlRegisterSingletonType(Models, "UM", 1, 0, "Models", Bindings.createModels) qmlRegisterSingletonType(ResourcesProxy, "UM", 1, 0, "Resources", Bindings.createResourcesProxy) qmlRegisterSingletonType(OperationStackProxy.OperationStackProxy, "UM", 1, 0, "OperationStack", Bindings.createOperationStackProxy) qmlRegisterSingletonType(MeshFileHandlerProxy.MeshFileHandlerProxy, "UM", 1, 0, "MeshFileHandler", MeshFileHandlerProxy.createMeshFileHandlerProxy) qmlRegisterSingletonType(PreferencesProxy.PreferencesProxy, "UM", 1, 0, "Preferences", PreferencesProxy.createPreferencesProxy) qmlRegisterSingletonType(Theme.Theme, "UM", 1, 0, "Theme", Theme.createTheme) qmlRegisterSingletonType(ActiveToolProxy.ActiveToolProxy, "UM", 1, 0, "ActiveTool", ActiveToolProxy.createActiveToolProxy) qmlRegisterSingletonType(ActiveViewProxy.ActiveViewProxy, "UM", 1, 0, "ActiveView", ActiveViewProxy.createActiveViewProxy) qmlRegisterSingletonType(SelectionProxy.SelectionProxy, "UM", 1, 0, "Selection", SelectionProxy.createSelectionProxy) qmlRegisterUncreatableType(Duration, "UM", 1, 0, "Duration", "") qmlRegisterUncreatableType(DurationFormat, "UM", 1, 0, "DurationFormat", "") # Additions after 15.06. Uses API version 1.1 so should be imported with "import UM 1.1" qmlRegisterType(OutputDevicesModel.OutputDevicesModel, "UM", 1, 1, "OutputDevicesModel") qmlRegisterType(i18nCatalogProxy.i18nCatalogProxy, "UM", 1, 1, "I18nCatalog") qmlRegisterType(MachineDefinitionsModel.MachineDefinitionsModel, "UM", 1, 1, "MachineDefinitionsModel") qmlRegisterType(MachineInstancesModel.MachineInstancesModel, "UM", 1, 1, "MachineInstancesModel") qmlRegisterType(MachineVariantsModel.MachineVariantsModel, "UM", 1, 1, "MachineVariantsModel") qmlRegisterType(ProfilesModel.ProfilesModel, "UM", 1, 1, "ProfilesModel") qmlRegisterSingletonType(OutputDeviceManagerProxy.OutputDeviceManagerProxy, "UM", 1, 1, "OutputDeviceManager", OutputDeviceManagerProxy.createOutputDeviceManagerProxy) qmlRegisterSingletonType(MachineManagerProxy.MachineManagerProxy, "UM", 1, 1, "MachineManager", MachineManagerProxy.createMachineManagerProxy)
def register(self): qmlRegisterType(MainWindow.MainWindow, "UM", 1, 0, "MainWindow") qmlRegisterType(ViewModel.ViewModel, "UM", 1, 0, "ViewModel") qmlRegisterType(ToolModel.ToolModel, "UM", 1, 0, "ToolModel") qmlRegisterType(JobsModel.JobsModel, "UM", 1, 0, "JobsModel") qmlRegisterType(AngledCornerRectangle.AngledCornerRectangle, "UM", 1, 0, "AngledCornerRectangle") qmlRegisterType(PointingRectangle.PointingRectangle, "UM", 1, 0, "PointingRectangle") qmlRegisterType(ExtensionModel.ExtensionModel, "UM", 1, 0, "ExtensionModel") qmlRegisterType(PluginsModel.PluginsModel, "UM", 1, 0, "PluginsModel") qmlRegisterType(VisibleMessagesModel.VisibleMessagesModel, "UM", 1, 0, "VisibleMessagesModel") # Singleton proxy objects qmlRegisterSingletonType(ControllerProxy.ControllerProxy, "UM", 1, 0, "Controller", Bindings.createControllerProxy) qmlRegisterSingletonType(ApplicationProxy.ApplicationProxy, "UM", 1, 0, "Application", Bindings.createApplicationProxy) qmlRegisterSingletonType(BackendProxy.BackendProxy, "UM", 1, 0, "Backend", Bindings.createBackendProxy) qmlRegisterSingletonType(SceneProxy.SceneProxy, "UM", 1, 0, "Scene", Bindings.createSceneProxy) qmlRegisterSingletonType(ResourcesProxy.ResourcesProxy, "UM", 1, 0, "Resources", Bindings.createResourcesProxy) qmlRegisterSingletonType(OperationStackProxy.OperationStackProxy, "UM", 1, 0, "OperationStack", Bindings.createOperationStackProxy) qmlRegisterSingletonType(MeshFileHandlerProxy.MeshFileHandlerProxy, "UM", 1, 0, "MeshFileHandler", MeshFileHandlerProxy.createMeshFileHandlerProxy) qmlRegisterSingletonType(PreferencesProxy.PreferencesProxy, "UM", 1, 0, "Preferences", PreferencesProxy.createPreferencesProxy) qmlRegisterSingletonType(Theme.Theme, "UM", 1, 0, "Theme", Theme.createTheme) qmlRegisterSingletonType(ActiveToolProxy.ActiveToolProxy, "UM", 1, 0, "ActiveTool", ActiveToolProxy.createActiveToolProxy) qmlRegisterSingletonType(ActiveViewProxy.ActiveViewProxy, "UM", 1, 0, "ActiveView", ActiveViewProxy.createActiveViewProxy) qmlRegisterSingletonType(SelectionProxy.SelectionProxy, "UM", 1, 0, "Selection", SelectionProxy.createSelectionProxy) qmlRegisterUncreatableType(Duration, "UM", 1, 0, "Duration", "") qmlRegisterUncreatableType(DurationFormat, "UM", 1, 0, "DurationFormat", "") # Additions after 15.06. Uses API version 1.1 so should be imported with "import UM 1.1" qmlRegisterType(OutputDevicesModel.OutputDevicesModel, "UM", 1, 1, "OutputDevicesModel") qmlRegisterType(i18nCatalogProxy.i18nCatalogProxy, "UM", 1, 1, "I18nCatalog") qmlRegisterSingletonType(OutputDeviceManagerProxy.OutputDeviceManagerProxy, "UM", 1, 1, "OutputDeviceManager", OutputDeviceManagerProxy.createOutputDeviceManagerProxy) # Additions after 2.1. Uses API version 1.2 qmlRegisterType(UM.Settings.Models.SettingDefinitionsModel, "UM", 1, 2, "SettingDefinitionsModel") qmlRegisterType(UM.Settings.Models.DefinitionContainersModel, "UM", 1, 2, "DefinitionContainersModel") qmlRegisterType(UM.Settings.Models.InstanceContainersModel, "UM", 1, 2, "InstanceContainersModel") qmlRegisterType(UM.Settings.Models.ContainerStacksModel, "UM", 1, 2, "ContainerStacksModel") qmlRegisterType(UM.Settings.Models.SettingPropertyProvider, "UM", 1, 2, "SettingPropertyProvider") qmlRegisterType(UM.Settings.Models.SettingPreferenceVisibilityHandler, "UM", 1, 2, "SettingPreferenceVisibilityHandler")
def setTarget(self, target): self._target = target @pyqtSlot() def advance(self): self._line += 1 if self._line < len(self._lyrics): self._target.write(self._lyrics[self._line]) else: QCoreApplication.instance().quit() app = QCoreApplication(sys.argv) qmlRegisterType(BirthdayPartyAttached) qmlRegisterType(BirthdayParty, "People", 1, 0, "BirthdayParty", attachedProperties=BirthdayPartyAttached) qmlRegisterType(HappyBirthdaySong, "People", 1, 0, "HappyBirthdaySong") qmlRegisterType(ShoeDescription) qmlRegisterType(Person) qmlRegisterType(Boy, "People", 1, 0, "Boy") qmlRegisterType(Girl, "People", 1, 0, "Girl") engine = QQmlEngine() component = QQmlComponent(engine) component.setData(QML, QUrl()) party = component.create()
@pyqtProperty(Person) def host(self): return self._host @host.setter def host(self, host): self._host = host @pyqtProperty(QQmlListProperty) def guests(self): return QQmlListProperty(Person, self, self._guests) app = QCoreApplication(sys.argv) qmlRegisterType(BirthdayParty, "People", 1, 0, "BirthdayParty") qmlRegisterType(Person) qmlRegisterType(Boy, "People", 1, 0, "Boy") qmlRegisterType(Girl, "People", 1, 0, "Girl") engine = QQmlEngine() component = QQmlComponent(engine) component.setData(QML, QUrl()) party = component.create() if party is not None and party.host is not None: print("\"%s\" is having a birthday!" % party.host.name) if isinstance(party.host, Boy):
from PyQt5.QtQml import qmlRegisterType from .loader import ImageDescriptor, ImageLoader MAJOR_VER = 1 MINOR_VER = 0 qmlRegisterType(ImageDescriptor, 'ImgLoader', MAJOR_VER, MINOR_VER, 'ImageDescriptor') qmlRegisterType(ImageLoader, 'ImgLoader', MAJOR_VER, MINOR_VER, 'ImageLoader')
def onTraitChanged(self, trait, selected): mode = selected != isinstance(trait, model.Perk) self.ap += trait.cost if mode else -trait.cost if selected: ok = True for c in trait.conditions: c*k = c.eval(self) ok = ok and c*k logger.info("checking %s --> %s", c, "ok" if c*k else "failed") if ok: self.traitLevels[trait] = 1 else: self.traitLevels[trait] = 0 logger.info("check failed") else: self.traitLevels[trait] = 0 @pyqtSlot(QObject, bool) def onSelectionChanged(self, c, selected): logger.info("%s %s", "selected: " if selected else "deselected:", c) try: handler = self.selectionHandlers[c.__class__] except KeyError: return handler(self, c, selected) qmlRegisterType(Character, 'dsa5', 1, 0, 'character') qmlRegisterType(NameValuePair, 'dsa5', 1, 0, 'name_value_pair') Character.initClass()
loaded = pyqtSignal() error = pyqtSignal(str, arguments=["errorText"]) metaDataChanged = pyqtSignal() @pyqtProperty("QVariantMap", notify=metaDataChanged) def metaData(self): return self._metadata @pyqtProperty(str, notify=loaded) def definitionId(self): return self._definition_id signal.signal(signal.SIGINT, signal.SIG_DFL) file_name = None if len(sys.argv) > 1: file_name = sys.argv[1] del sys.argv[1] app = QApplication(sys.argv) engine = QQmlApplicationEngine() qmlRegisterType(DefinitionLoader, "Example", 1, 0, "DefinitionLoader") qmlRegisterType(DefinitionTreeModel.DefinitionTreeModel, "Example", 1, 0, "DefinitionTreeModel") if file_name: engine.rootContext().setContextProperty("open_file", QUrl.fromLocalFile(file_name)) engine.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), "main.qml")) app.exec_()
self._host = host @pyqtProperty(QQmlListProperty) def guests(self): return QQmlListProperty(Person, self, self._guests) def guestCount(self): return len(self._guests) def guest(self, idx): return self._guests[idx] app = QCoreApplication(sys.argv) qmlRegisterType(BirthdayParty, "People", 1, 0, "BirthdayParty") qmlRegisterType(Person, "People", 1, 0, "Person") engine = QQmlEngine() component = QQmlComponent(engine) component.setData(QML, QUrl()) party = component.create() if party is not None and party.host is not None: print("\"%s\" is having a birthday!" % party.host.name) print("They are inviting:") for ii in range(party.guestCount()): print(" \"%s\"" % party.guest(ii).name)
init_subsystem() #raw_test3() app = QApplication(sys.argv) engine = QQmlEngine(app) #engine = QQmlApplicationEngine() # doesn't quite work because we aren't actually using the component associated # with this engine engine.quit.connect(app.quit) # from http://pyqt.sourceforge.net/Docs/PyQt5/qml.html # Register the Python type. Its URI is 'People', it's v1.0 and the type # will be called 'Person' in QML. qmlRegisterType(Weather, 'WeatherCategory', 1, 0, 'Weather') qmlRegisterType(DataPoint, 'WeatherCategory', 1, 0, 'DataPoint') qmlRegisterType(DataBlock, 'WeatherCategory', 1, 0, 'DataBlock') qmlRegisterType(Geocoder, 'WeatherCategory', 1, 0, 'Geocoder') component = QQmlComponent(engine) component.loadUrl(QUrl('WeatherDash.qml')) # Create the QML user interface. Auto creates its own engine view = QQuickView() engine2 = view.engine # Does not run #engine2.quit.connect(app.quit) #view.setSource(QUrl('PyTest.qml'))
def registerTypes(self): qmlRegisterType(Person, 'People', 1, 0, 'Person')
def register_types(): qmlRegisterType( HUD, 'Nube.Core', 0,1, 'HUD' ) qmlRegisterType( Style, 'Nube.Core', 0,1, 'Style', attachedProperties = StyleAttached )
# -*- coding: utf-8 -*- import os, sys, re from PyQt5.QtNetwork import * from fboinsgrenderer import * from textureinsgnode_rc import * from PyQt5.QtGui import QSurfaceFormat from PyQt5.QtWidgets import QApplication from PyQt5.QtCore import (QVariant, QUrl, QDir, QSortFilterProxyModel, pyqtProperty, QSize, Q_ENUMS, QObject, QRegExp, QAbstractItemModel, pyqtSignal, Qt, QModelIndex, QByteArray) from PyQt5.QtQml import (QQmlApplicationEngine, QQmlEngine, QQmlFileSelector, qmlRegisterType, QQmlParserStatus, QJSValue) from PyQt5.QtQuick import QQuickView, QQuickItem, QQuickWindow if __name__ == '__main__': app = QApplication(sys.argv) qmlRegisterType(FboInSGRenderer, "SceneGraphRendering", 1, 0, "Renderer") widgetWindow = QQuickView() widgetWindow.setResizeMode(QQuickView.SizeRootObjectToView) widgetWindow.setSource(QUrl("qrc:///main.qml")) widgetWindow.show() sys.exit(app.exec_())
from PyQt5.QtQuick import QQuickView from PyQt5.QtWidgets import QApplication from qtypes.argv import ArgParser from qtypes.vend import Vend if __name__ == '__main__': # Reminder to self, see link for why we avoid a 'main' function here # http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#object-destruction-on-exit app = QApplication(sys.argv) print(sys.version) print("InvoiceIt") root = os.path.dirname(__file__) app.setApplicationName("InvoiceIt") app.setApplicationDisplayName("InvoiceIt") app.setApplicationVersion("0.1") view = QQuickView() qmlRegisterType(ArgParser, "ArgV", 1, 0, "ArgParser") qmlRegisterType(Vend, "Vend", 1, 0, "Vendor") f = QUrl.fromLocalFile(join(root, 'qml', 'main.qml')) view.setResizeMode(QQuickView.SizeRootObjectToView) view.setSource(f) view.show() sys.exit(app.exec_())
#!/usr/bin/python3 # -*- coding: utf-8 -*- import sys from PyQt5.QtCore import QUrl from PyQt5.QtQml import qmlRegisterType from PyQt5.QtGui import QGuiApplication from PyQt5.QtQuick import QQuickView from dpcs.speaker import Speaker from dpcs.qmlmodel import Database, Category, Symbol app = QGuiApplication(sys.argv) qmlRegisterType(Speaker, 'DPCS', 1, 0, 'Speaker') qmlRegisterType(Database, 'DPCS', 1, 0, 'Database') qmlRegisterType(Category, 'DPCS', 1, 0, 'Category') qmlRegisterType(Symbol, 'DPCS', 1, 0, 'Symbol') view = QQuickView() view.engine().quit.connect(app.quit) view.setSource(QUrl('main.qml')) view.show() sys.exit(app.exec_())
def registerObjects(self, engine): engine.rootContext().setContextProperty("Printer", self) engine.rootContext().setContextProperty("CuraApplication", self) self._print_information = PrintInformation.PrintInformation() engine.rootContext().setContextProperty("PrintInformation", self._print_information) self._cura_actions = CuraActions.CuraActions(self) engine.rootContext().setContextProperty("CuraActions", self._cura_actions) qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type") qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel") qmlRegisterType(cura.Settings.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel") qmlRegisterSingletonType(cura.Settings.ProfilesModel, "Cura", 1, 0, "ProfilesModel", cura.Settings.ProfilesModel.createProfilesModel) qmlRegisterType(cura.Settings.QualityAndUserProfilesModel, "Cura", 1, 0, "QualityAndUserProfilesModel") qmlRegisterType(cura.Settings.UserProfilesModel, "Cura", 1, 0, "UserProfilesModel") qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler") qmlRegisterType(cura.Settings.QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel") qmlRegisterType(cura.Settings.MachineNameValidator, "Cura", 1, 0, "MachineNameValidator") qmlRegisterSingletonType(cura.Settings.ContainerManager, "Cura", 1, 0, "ContainerManager", cura.Settings.ContainerManager.createContainerManager) # As of Qt5.7, it is necessary to get rid of any ".." in the path for the singleton to work. actions_url = QUrl.fromLocalFile(os.path.abspath(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml"))) qmlRegisterSingletonType(actions_url, "Cura", 1, 0, "Actions") engine.rootContext().setContextProperty("ExtruderManager", cura.Settings.ExtruderManager.getInstance()) for path in Resources.getAllResourcesOfType(CuraApplication.ResourceTypes.QmlFiles): type_name = os.path.splitext(os.path.basename(path))[0] if type_name in ("Cura", "Actions"): continue qmlRegisterType(QUrl.fromLocalFile(path), "Cura", 1, 0, type_name)
@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_())
from sqlalchemy import and_, or_ cards = session.query(Card).filter( and_(Card.name.like('%{0}%'.format(text)), Card.collectible == 1, or_(Card.type == CardType.SPELL.value, Card.type == CardType.WEAPON.value, Card.type == CardType.MINION.value))) cards = cards.order_by(Card.cost).order_by(Card.type.asc()). \ order_by(Card.name.asc()).limit(8).all() model.reset() model.add_cards(cards) if __name__ == "__main__": import pdb app = QApplication(sys.argv) # Register the Python type. Its URI is 'People', it's v1.0 and the type # will be called 'Person' in QML. qmlRegisterType(TrackedCard, 'TrackedCards', 1, 0, 'TrackedCard') engine = QQmlApplicationEngine() ctxt = engine.rootContext() # Initialize the data base sqlengine = create_engine('sqlite:///stats.db', echo=False) Session = sessionmaker() Session.configure(bind=sqlengine) session = Session() ctxt.setContextProperty('pythonList', model) engine.load(QUrl('vt.qml')) engine.quit.connect(app.quit) autoComplete = engine.rootObjects()[0].findChild(QObject, 'autoComplete') autoComplete.textModified.connect(onTextChanged) # data = engine.rootObjects()[0].findChild(QObject, 'myList')