def OnAdd(self, evt):
dialog = wx.TextEntryDialog(self,
"Enter name:",
"Add", style = wx.OK | wx.CANCEL)
dialog.Centre(wx.BOTH)
if dialog.ShowModal() == wx.ID_OK:
name = dialog.GetValue()
if name not in ("CURRENT", ) and name not in self.all_hosts:
fpath = os.path.join(DataPath, name)
shutil.copy(os.path.join(DataPath, "default"), fpath)
call_editor(fpath)
self.all_hosts.append(name)
self.combo_box_1.AppendItems([name])
else:
msg_dialog = wx.MessageDialog(self,
"Failed to create \"%s\".\nFile already exists." % name,
'Failed to create "%s"' % name, wx.OK | wx.ICON_ERROR)
msg_dialog.Centre(wx.BOTH)
msg_dialog.ShowModal()
msg_dialog.Destroy()
dialog.Destroy()
评论列表
文章目录