I’m using entrycget to get the relevant variable values from a widget.
my $selectedItem = $tree->entrycget(<label>, <data>);
The label is an entry indicating the level of the tree, for example the second sub-node of the node 1 of root node will be denoted as
'Root/node1/node2'
Data is the value I want to retrieve, in this case a file path. However, there are duplicate entries for data, as an example Root/node1 and Root/node1/node2 can both have same data value (same path).
In retrieving the value of the selected tree item, I found out that it is not returning the value correctly for some labels, typically when there is a another duplicate entry for the data field, as in the scenario above. Is this caused by having duplicate data field? How does the entrycget method work?
The
entrycgetmethod works on the underlying model of the tree. It maps the path argument (<label>in your question) to a particular node in that tree, and then uses the option argument (<data>in your question) to pick a field out of the node structure, returning the relevant value.So far as the widget is concerned, duplicate options are no problem as it the path that is the unique part (and prefixes of the path will have values set).