def __init__(self, c): '''Ctor for NbController class.''' self.c = c self.gnxcache = {} self.mw = ModelWrapper(["h", "b", "gnx", "level", "style"]) #self.add_all_nodes() #self.add_subtree(p) try: # pylint: disable=no-name-in-module from PyQt5.QtQuick import QQuickView self.view = view = QQuickView() except Exception: #1746. self.view = view = QtDeclarative.QDeclarativeView() ctx = view.rootContext() @g.command("nb-all") def nb_all_f(event): self.add_all_nodes() self.view.show() @g.command("nb-subtree") def nb_subtree_f(event): p = self.c.p self.add_subtree(p) self.view.show() ctx.setContextProperty("nodesModel", self.mw.model) path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml', 'leonbmain.qml') view.setSource(QtCore.QUrl(path)) if isQt5 or isQt6: mode = view.SizeRootObjectToView else: mode = QtDeclarative.QDeclarativeView.SizeRootObjectToView view.setResizeMode(mode) # Display the user interface and allow the user to interact with it. view.hide() view.setGeometry(100, 100, 800, 600) #view.show() c.dummy = view
def __init__(self, c): self.c = c self.gnxcache = {} self.mw = ModelWrapper(["h", "b", "gnx", "level", "style"]) #self.add_all_nodes() #self.add_subtree(p) self.view = view = QtDeclarative.QDeclarativeView() ctx = view.rootContext() @g.command("nb-all") def nb_all_f(event): self.add_all_nodes() self.view.show() @g.command("nb-subtree") def nb_subtree_f(event): p = self.c.p self.add_subtree(p) self.view.show() ctx.setContextProperty("nodesModel", self.mw.model) path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml', 'leonbmain.qml') view.setSource(QtCore.QUrl(path)) view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView) # Display the user interface and allow the user to interact with it. view.hide() view.setGeometry(100, 100, 800, 600) #view.show() c.dummy = view