如何解决如何从我的数据集中删除已从KivyMD的GUI中删除的项目
当我按下垃圾箱图标按钮时,所选的OneLineListItem从GUI中删除。不幸的是,它没有从我的数据表中删除,因此当我重新启动应用程序时它将再次出现。但是我不知道如何将方法on_start / remove_item与我的数据表连接。您有什么想法可以解决这个问题吗?
仅是代码的重要部分
class MainApp(MDApp):
def build(self):
self.theme_cls.primary_palette = "BlueGray"
def on_start(self):
df = pd.read_csv("date.csv",index_col=False)
for i in df.index:
self.root.ids.md_list.add_widget(
SwipeToDelete(text=df["Name"][i])
)
def remove_item(self,instance):
df = pd.read_csv("date.csv")
self.root.ids.md_list.remove_widget(instance)
还有我的东西(仅是重要部分)
<SwipeToDelete>:
size_hint: 0.8,0.8
pos_hint: {"center_x": 0.5,"center_y": 0.5}
height: content.height
type_swipe: "hand"
anchor:"left"
MDCardSwipeLayerBox:
padding: "8dp"
MDIconButton:
icon:"trash-can"
pos_hint: {"center_x":0.5,"center_y":0.5}
on_release:
app.remove_item(root)
MDCardSwipeFrontBox:
TwoLineIconListItem:
id: content
text: root.text
secondary_text: app.get_date_item()
_no_ripple_effect: True
IconLeftWidget:
icon:"account"
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。