Beispiel #1
0
    def newHosts(self, event=None, default=""):
        u"""新建一个 hosts"""

        global g_local_hosts_dir

        repeat = False
        title = default

        dlg = wx.TextEntryDialog(None, u"新建 hosts", u"输入 hosts 名:", title, style=wx.OK | wx.CANCEL)
        if dlg.ShowModal() == wx.ID_OK:
            title = dlg.GetValue().strip()

            if title:

                oh = self.getOHostsFromTitle(title)
                if oh:

                    repeat = True
                    self.alert(u"命名失败!", u"名为 '%s' 的 hosts 已经存在了!" % title)

                else:
                    # 保存新文件

                    path = self.mkNewHostsPath()
                    c = u"# %s" % title
                    oh = Hosts(path=path)
                    oh.setTitle(title)
                    oh.setContent(c)
                    self.updateHostsList()

        dlg.Destroy()

        if repeat:
            self.newHosts(event, default=title)
Beispiel #2
0
    def newHosts(self, event=None, default=""):
        u"""新建一个 hosts"""

        global g_local_hosts_dir

        repeat = False
        title = default

        self.newHosts_test()
        return

        dlg = wx.TextEntryDialog(None,
                                 u"新建 hosts",
                                 u"输入 hosts 名:",
                                 title,
                                 style=wx.OK | wx.CANCEL)
        if dlg.ShowModal() == wx.ID_OK:
            title = dlg.GetValue().strip()

            if title:

                oh = self.getOHostsFromTitle(title)
                if oh:

                    repeat = True
                    self.alert(u"命名失败!", u"名为 '%s' 的 hosts 已经存在了!" % title)

                else:
                    # 保存新文件

                    path = self.mkNewHostsPath()
                    c = u"# %s" % title
                    oh = Hosts(path=path)
                    oh.setTitle(title)
                    oh.setContent(c)
                    self.updateHostsList()

        dlg.Destroy()

        if repeat:
            self.newHosts(event, default=title)