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.
ui.tableview does not update screen
-
Hi all,
I run in a problem that a ui.tableview does not update the screen after changing the content. Only after moving/scrolling the ui.tableview up and down the new content will be shown.
The code is only for demo, i real I get the content from sqlite and try to update after filtering. UI has only "tableview1" and "button1".
# coding: utf-8 import ui def buttonaction(sender): Liste = [] for i in range(20,30): Liste.append('Neu-Kram '+str(i)) lst = ui.ListDataSource(Liste) v['tableview1'].data_source = lst v['tableview1'].reload v['tableview1'].set_needs_display() v.set_needs_display() def init(): Liste = [] for i in range(1,10): Liste.append('Kram '+str(i)) lst = ui.ListDataSource(Liste) v['tableview1'].data_source = lst v = ui.load_view() init() v['button1'].action = buttonaction v.present('sheet')
Any hints what I am doing wrong?
Regards
Tom -
Change
v['tableview1'].reload
tov['tableview1'].reload()
.The parenthisis at the end will cause the function to be called and then magic will happen.
-
Sometimes its so easy..... Thanks a lot!
-
Another approach is to replace the
.data_source.items
and then you do not even need to callreload()
.# coding: utf-8 import ui def init(): Liste = ['Kram {}'.format(i) for i in xrange(1,10)] v['tableview1'].data_source.items = Liste def buttonaction(sender): Liste = ['Neu-Kram {}'.format(i) for i in xrange(20,30)] v['tableview1'].data_source.items = Liste v = ui.load_view() init() v['button1'].action = buttonaction v.present('sheet')