?????????????????У??????????host???л??????host??????????????????????
????????????????drivers/etc/hosts?????????ip????????????host??????????
????????????????host????л???????????????????host????????????????У?????鷳??
???????????????notepad++??notepad??hosts???????????????????ip?????????????????Ч??
?????????к???л?host??????????switchhosts?????????????????????????С???????????С????????????????????????host???????????????????
????????????????
????#coding:utf-8
????import wx
????import os
????class Frame(wx.Frame):
????def __init__(self):#????????????????
????wx.Frame.__init__(self??None??-1??'SwithHosts Example'??size=(1000??600))
????panel=wx.Panel(self??-1)
????ReadButton = wx.Button(panel?? label = u'??host'??pos = (225??5)??size = (80??25))
????ReadButton.Bind(wx.EVT_BUTTON?? self.Read)#??button??????
????saveButton = wx.Button(panel?? label = u'????host'??pos = (315??5)??size = (80??25))
????saveButton.Bind(wx.EVT_BUTTON??self.Save)#??button??????
????self.filename = 'C:WindowsSystem32driversetchosts'#host???·??
????self.contents = wx.TextCtrl(panel?? pos = (5??35)??size = (500??250)?? style = wx.TE_MULTILINE)
????hbox=wx.BoxSizer()
????hbox.Add(ReadButton??proportion=0??flag=wx.RIGHT|wx.HORIZONTAL)
????hbox.Add(saveButton??proportion=0??flag=wx.RIGHT|wx.HORIZONTAL)
????hbox.Add(self.contents??proportion=1??flag=wx.EXPAND|wx.ALL)
????panel.SetSizer(hbox)
????def Read(self??event):#???host???????????????
????file = open(self.filename)
????all_the_text=file.read()
????self.contents.SetValue(all_the_text)
????def Save(self??event):#????????е??????????д??host??
????value=self.contents.GetValue()
????file = open(self.filename??'w')
????file.write(value)
????file.close()
????if __name__ == "__main__":
????app=wx.PySimpleApp()
????frame=Frame()
????frame.Show()
????app.MainLoop()
????????????Ч??


????