hostswitcher.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:hostswitcher 作者: fiefdx 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号