hostswitcher.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号