def __init__(self, wikis):
addbtn = ui.ButtonItem(image=ui.Image.named('iob:ios7_plus_empty_32'),
action=self.add)
# self.editbtn so it can be used in WikiList.edit
self.editbtn = ui.ButtonItem(title='Edit', action=self.edit)
items = None
# If save file exists use it
if os.path.isfile(os.path.expanduser('~/.mwsave.dat')):
s = shelve.open(os.path.expanduser('~/.mwsave'))
try:
wikis = s['wikis']
except KeyError:
pass
s.close()
self.tv = ui.TableView(name='Wikis')
self.nv = ui.NavigationView(self.tv)
self.tv.delegate = TableViewDelegate(wikis)
items = []
# Create data source from dictionary of wikis
for wiki in wikis:
items.append({'title': wiki,
'accessory_type': 'detail_disclosure_button'})
self.tv.data_source = ui.ListDataSource(items)
self.tv.data_source.move_enabled = True
self.tv.data_source.edit_action = self.removeFromWikis
self.tv.right_button_items = [addbtn]
self.tv.left_button_items = [self.editbtn]
self.nv.present('fullscreen', hide_title_bar=True)
# Wait until the view closes to save app data
self.nv.wait_modal()
self.save()
评论列表
文章目录