Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Names of selected rows instead of numbers
-
This gives me a list index out of range
-
print(sender, sender.selected_row, sender.items)
-
@ccc Thanks, but is there a way to display the title? Trying to get the editor to open when a row is selected. The data is from a directory.
-
-
-
-
@techteej The line that might interest you the most is...
self.sRow = sender.tableview.data_source.items[sender.tableview.selected_row[1]]['title']
-
@tony I get the error NoneType has no attribute data_source
-
@techteej You've a working example in the Menu class that you can check your coding against if you like.
-
@techteej You can simplify my line so that it's like @ccc's above (Menu was one of the first things I wrote and I've gone up in order to come back down again to where I was, but there were no examples to follow that I could find when I started)
self.sRow = sender.items[sender.selected_row]['title']
It's telling you what you already know I'm sure, but:
- you should be in a ListDataSource action when you use the line, so sender is one of those
- the items are a list of dicts... so first you need the row number to get the correct entry from the list... and then you can use the entry as a dict to look up the title
Hope it helps.