def OnSet(self, evt):
name = self.combo_box_1.GetValue()
fpath = os.path.join(DataPath, name)
msg_dialog = wx.MessageDialog(self,
"Are you sure that you want to set file \"%s\" as current hosts" % name,
"Set \"%s\"" % name, wx.YES_NO | wx.ICON_EXCLAMATION)
msg_dialog.Centre(wx.BOTH)
r = msg_dialog.ShowModal()
if r == wx.ID_YES:
with open(fpath, "rb") as fp_src:
with open("/etc/hosts", "wb") as fp_des:
fp_des.write(fp_src.read())
self.current = name
with open(CurrentHosts, "wb") as fp:
fp.write(name)
self.statusbar.SetStatusText("Current: %s" % self.current)
msg_dialog.Destroy()
评论列表
文章目录