Hi. Dear @JonB and @enceladus . I am grateful for your help. I looked at some examples of ‘navigation view’ and ‘tableview’ on GitHub.
I could understand how I can make and run the UI program with Navigation View, and I wrote some prototypes using templates.
However, I want to get the value of the selected item in the navigation view, but I failed to get it even though I searched how I can.
Here is a code which I wrote. When I made the program run, the console said ‘AttributeError: 'ShowTableView' object has no attribute 'selected_row'’.
I'm sorry for the second request but could you teach me how I can change it or show me the templates?
import console, os, ui
import ui
import os
class ShowTableView(object):
def __init__(self):
self.view = ui.load_view("ShowTableView")
self.view.present("sheet")
self.view.name = "Select"
self.bt_empty_action(None)
dir_items =(‘a’, ‘b’, ‘c’, ‘d’, ‘e’)
tv1 = self.view["tableview1"]
tv1.data_source = tv1.delegate = ui.ListDataSource(dir_items)
tv1.data_source.delete_enabled = tv1.editing = False
tv1.reload_data()
def bt_dir_action(self, sender):
sel = self.selected_row
item = sender.items[sel]
label.text = item.text
@ui.in_background
def tv1_action(self, sender):
info = sender.items[sender.selected_row]
console.alert("info", "\n".join(["{} = {}".format(i, info[i]) for i in info]))
ShowTableView()