I want to refresh Tableview data from a dictionary by selecting a row in the Tableview. This code works fine the first time but then dies.
I’ve run into many errors: recursion, referenced before assigning, not defined, etc.
Can anyone suggest where I’ve gone wrong with my logic or my coding?
import ui, console
view=ui.View()
view.frame=(0,0,400,400)
d1={
'quantity':['energy','space'],
'space':['time','quantity'],
'time':['space','quantity'],
}
#------------------------------------
def cell_tapped1(sender):
cellval1 = ds1.selected_row
ll01=cps[cellval1]
ll01=ll01.strip()
cell_tapped2(ll01)
#-------------------------------------
def cell_tapped3(self):
ds3=ui.ListDataSource(cpss)
ds3.action=cell_tapped3
tv1.data_source=tv1.delegate
cellval1 = ds3.selected_row
ll01=cpss[cellval1]
ll01=ll01.strip()
cell_tapped2(ll01)
#_#-----------------------------------
def cell_tapped2(ll01):
cpss=[]
cpss.append(ll01)
for i in d1[ll01]:
cpss.append(' '+i)
ds3=ui.ListDataSource(cpss)
ds3.action=cell_tapped3
tv1.data_source=tv1.delegate=ds3
tv1.reload_data()
#console.clear()
for i in cpss:
print (i)
#-----------------------------------------
tv1=ui.TableView()
tv1.width,tv1.height=400,350
cps=[]
cps.append('space')
cps.append('time')
cps.append('quantity')
ds1=ui.ListDataSource(cps)
ds1.action=cell_tapped1
tv1.data_source=tv1.delegate=ds1
view.add_subview(tv1)
view.present('sheet')