Forum Archive

TableView help

Dann239

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!

JonB

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()
henryiii

I think you need [1] after table.selected_row, as it returns a 2d location.

Dann239

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')
omz

@Dann You probably meant self['tableview1'] instead of View['tableview1'].

Dann239

@omz thank you, of course I probably meant that. -_______-