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.
TableView help
-
Please forgive me if this seems simple, I am confused on how to pass a list or dict to ListDataSource. I am a bit over my head but I want to iterate over a parsed rss feed and pass the new dict to ListDataSource and TableView.
Thanks for any help or pointers!
-
Here's a simple example
def tabletest(): mylist=['item a', 'item b', 'item c'] table=ui.TableView() listsource=ui.ListDataSource(my list) listsource.font=('<system>',10) listsource.action=_tapaction table.data_source=listsource table.delegate=listsource table.width=300 table.height=300 table.row_height=15 table.present('popover') table.wait_modal() print mylist[table.selected_row] def _tapaction(sender): sender.tableview.close() tabletest()
-
I think you need [1] after table.selected_row, as it returns a 2d location.
-
That did clear up a few things. My struggle is now with connecting the list data to UI builder. What am I missing?
import ui class View (ui.View): def did_load(self): mylist = ['item a', 'item b', 'item c'] listsource = ui.ListDataSource(mylist) View['tableview1'].data_source = listsource ui.load_view('Table').present('popover')
-
@Dann You probably meant
self['tableview1']
instead ofView['tableview1']
. -
@omz thank you, of course I probably meant that. -_____________-