def OnDelete(self, evt):
name = self.combo_box_1.GetValue()
fpath = os.path.join(DataPath, name)
if name != "default":
msg_dialog = wx.MessageDialog(self,
"Are you sure that you want to delete file \"%s\"" % name,
"Delete \"%s\"" % name, wx.YES_NO | wx.ICON_EXCLAMATION)
msg_dialog.Centre(wx.BOTH)
r = msg_dialog.ShowModal()
if r == wx.ID_YES:
if os.path.exists(fpath) and os.path.isfile(fpath):
os.remove(fpath)
index = self.combo_box_1.GetSelection()
self.combo_box_1.Delete(index)
self.combo_box_1.Select(0)
msg_dialog.Destroy()
else:
msg_dialog = wx.MessageDialog(self,
"\"%s\" can't be deleted.\nYou can edit it only." % name,
"\"%s\" can't be deleted." % name, wx.OK | wx.ICON_ERROR)
msg_dialog.Centre(wx.BOTH)
msg_dialog.ShowModal()
msg_dialog.Destroy()
评论列表
文章目录