Getting the row number of Gtk TreeView

后端 未结 1 754
慢半拍i
慢半拍i 2021-01-13 21:29

I have a GTk TreeView called MyTree with the following data as presented below,

DTime  ATime Transfer Platform

14:30    15:20    0       2a         


        
相关标签:
1条回答
  • 2021-01-13 21:51

    Since you are in BROWSE selection mode, you know there is only one selected row. Then, you can get the path to the first selected item doing

    path = iter.get_selected_rows()[0]
    

    Then, if your tree has only one level (e.g. it is not a nested tree), you can get the index from the path like this

    index = path.get_indices()[0]
    

    It seems complicated, but this is because you selection could contains many rows (this is why it returns a list) and because the tree can have many levels (this is why it returns a path).

    0 讨论(0)
提交回复
热议问题