Python Forum

Full Version: How to tagging items in QTreeWidget?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am pretty new in python (and this is my first post here). so Hello everyone!

I developed a Treeview widget using Tkinter. I used the next code sentence to create the Treeview items and subitems with Tkinter:
Treeview.insert("", END, text=NAMESTRUCTURE + lst_ws[n_sheet],                    
                iid=lst_ws[n_sheet], tags=("mytag",))


Treeview.insert(profile_split[0], END, text=NAMEPROFILE + profile_split[1],
                    iid=profile, tags=("mytag",))
Therefore, every item on Tkinter Treeview had its only specific "tag" and thanks to this method I was able to get coordinates of the item in the Treeview:

 def treeItemSel(self, event):
        # get the tree selected item
        tree_coords = (self.tree_view.winfo_pointerx() - self.tree_view.winfo_rootx(),
                       self.tree_view.winfo_pointery() - self.tree_view.winfo_rooty())
        tree_item = self.tree_view.identify('item', *tree_coords)
Currently I am migrating the previous python code because I want to use the QT GUI. But I am wondering how to create a Treeview with tags and how to get the coordinates of the Treeview items when one of them is selected.

Note: To create a Treeview with PyQt I used Qt.QTreeWidgetItem but it doesn't create a specific tag for every item.

The reason because I would like to have a "tag" or some kind of identification is because I want to load different pictures according to the treeview item selected. And the name of the pic is different to the name of the treeview item. So I need to find a solution in Qt GUI to make a relation between the name of the picture and name of the Qtreeview item. Any idea?

Thanks in advance.

Greetings

Greetings