Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.4k views
in Technique[技术] by (71.8m points)

python - 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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...