I'm having a problem on how can I remove an item from the list widget using a button and possibly how can I clear the widget after checking all the item.
py.file
class MenuScreen(Screen):
def add_item(self):
global lst
i = 0
if self.ids.inp.text == "":
close_button = MDFlatButton(text="Okay", on_release=self.close_dialog)
self.dialog = MDDialog(title="Invalid", text="No item added",
size_hint=(0.7, 1), buttons=[close_button])
self.dialog.open()
else:
list_items.append(self.ids.inp.text)
self.ids.inp.text = ''
for x in range(len(list_items)):
lst = OneLineAvatarIconListItem(text=list_items[i])
i += 1
self.ids.list.add_widget(lst)
def close_dialog(self, obj):
self.dialog.dismiss()
def remove_item(self):
pass
Example image:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…