I am creating an application with a Python 3 and PyQt5 where I have to generate tree view with any word. The preview will contain the data items in which the rows are created which are made from the dot value and the key pair. Value should be editable in the UI Now, it was easy enough to generate items from Dict with code:
def createTreeFromDict (self, data, guardian, top = false): ifinstance (data, dict): key Value in Value.items (): If isinstance (value, dict): node = tree ([key, ""] parent) parent.appendChild (node) self.createTreeFromDict (value, node) elif isinstance (value) , List): Node = treeItem ([key, ""] parent) parent.appendChild (node) self.createTreeFromDict (value, node) Other: print (key) print (value) node = TreeItem ([key, value ], Parent) Parent.appendChild (node) ifinstance (data, list): indicator Value for calculation (data): If isinstance (value, dict): node = triitum ([index + 1, ""], parent) parent.appendChild (node) self (image, value, list) : Node = treeitem ([index 1, ""], parent) parent.appendChild (node) self.createTreeFromDict (value, node) Other: node = tree (["juttu", value], parent) parent.appendChild (Node) if top: self.layoutChanged.emit ()
However, I am thinking that how should I basically pair it multilayer dictionary so that the user stops the value of an item Per can, it changes the value of the original term problem could that be hair Daikts and lists dict, so I could not keep the keys of the items with reference to the original dict.
I think I can do a frequent search through the original dictionary to find the right dick key-value pair, but first I would like to know the following would be possible:
< P> When I'm making items in the code at the top, you can see how I pass the new TreeItem key and value: node = TreeItem ([key, value], parent)
This reference contains a reference / no for this specific key-value pair in the original dictionary Etk also possible to pass? So if I edit the value of the reference, will it update the value in the original word? Or in other words how can I pass ["mykey"] as a "cowboy", which is in reference to the original thing?
No comments:
Post a Comment