Search code examples
pythongtkpygtk

How to get a list of the elements in TreeView? PyGtk


I have a treeview, with some elements in it. How can I get a list of all this data? Is there something similar to this,

self.treeview.GetItems()

Solution

  • I'd say you get the model:

    model = self.treeview.get_model()
    

    And then you have tons of different ways to access your data/items depending on what you want and how the model look... For more on that check http://pygtk.org

    You could get first row by doing:

    model[0]
    

    And also you could iterate through it...