2021年1月22日星期五

How to remove an item from the list widget using a button on kivymd

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: enter image description here

https://stackoverflow.com/questions/65855035/how-to-remove-an-item-from-the-list-widget-using-a-button-on-kivymd January 23, 2021 at 10:06AM

没有评论:

发表评论