⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abcoptiondlg.py

📁 BitTorrentABC-Linux-V.2.4.3源码
💻 PY
📖 第 1 页 / 共 2 页
字号:
        colsizer.Add(twocolsizer)

        savesizer = wxGridSizer(cols = 2, hgap = 20)
        okButton = wxButton(panel, -1, 'Apply')
        savesizer.Add(okButton, 0, wxALIGN_CENTER)

        cancelButton = wxButton(panel, -1, 'Cancel')
        savesizer.Add(cancelButton, 0, wxALIGN_CENTER)

        colsizer.Add(savesizer, 1, wxALIGN_CENTER)

        resizewarningtext1=StaticText('None of these settings will take effect until the next active torrent.', self.FONT-2)
        resizewarningtext2=StaticText('[Don\'t forget to click apply also in ABC preference menu]', self.FONT-2)

        colsizer.Add(resizewarningtext1, 1, wxALIGN_CENTER)
        colsizer.Add(resizewarningtext2, 1, wxALIGN_CENTER)

        border = wxBoxSizer(wxHORIZONTAL)
        border.Add(colsizer, 1, wxEXPAND | wxALL, 4)
        
        panel.SetSizer(border)
        panel.SetAutoLayout(true)

        def saveConfigs(self, ref = self):
          try:
            ref.advancedConfig['ip'] = ip_data.GetValue()
            ref.advancedConfig['bind'] = bind_data.GetValue()
            ref.advancedConfig['min_peers'] = minpeers_data.GetValue()
            ref.advancedConfig['alloc_type'] = alloctype_data.GetStringSelection()
            ref.advancedConfig['alloc_rate'] = int(allocrate_data.GetValue())
            try:
                ref.advancedConfig['max_files_open'] = int(maxfilesopen_data.GetStringSelection())
            except:       # if it ain't a number, it must be "no limit"
                ref.advancedConfig['max_files_open'] = 0
            try:
                ref.advancedConfig['max_connections'] = int(maxconnections_data.GetStringSelection())
                ref.advancedConfig['max_initiate'] = min(
                    2*ref.advancedConfig['min_peers'], ref.advancedConfig['max_connections'])
            except:       # if it ain't a number, it must be "no limit"
                ref.advancedConfig['max_connections'] = 0
                ref.advancedConfig['max_initiate'] = 2*ref.advancedConfig['min_peers']
            ref.advancedMenuBox.Close()
          except:
            pass # ???

        def cancelConfigs(self, ref = self):            
            ref.advancedMenuBox.Close()

        def ip_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\n\nThe IP reported to the tracker.\n' +
                                  'unless the tracker is on the\n' +
                                  'same intranet as this client,\n' +
                                  'the tracker will autodetect the\n' +
                                  "client's IP and ignore this\n" +
                                  "value.")

        def bind_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\n\nThe IP the client will bind to.\n' +
                                  'Only useful if your machine is\n' +
                                  'directly handling multiple IPs.\n' +
                                  "If you don't know what this is,\n" +
                                  "leave it blank.")

        def minpeers_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\n\nThe minimum number of peers the\n' +
                                  'client tries to stay connected\n' +
                                  'with.  Do not set this higher\n' +
                                  'unless you have a very fast\n' +
                                  "connection and a lot of system\n" +
                                  "resources.")

        def alloctype_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\nHow to allocate disk space.\n' +
                                  'normal allocates space as data is\n' +
                                  'received, background also adds\n' +
                                  "space in the background, pre-\n" +
                                  "allocate reserves up front, and\n" +
                                  'sparse is only for filesystems\n' +
                                  'that support it by default.')

        def allocrate_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\n\nAt what rate to allocate disk\n' +
                                  'space when allocating in the\n' +
                                  'background.  Set this too high on a\n' +
                                  "slow filesystem and your download\n" +
                                  "will slow to a crawl.")

        def maxfilesopen_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\n\nThe maximum number of files to\n' +
                                  'keep open at the same time.  Zero\n' +
                                  'means no limit.  Please note that\n' +
                                  "if this option is in effect,\n" +
                                  "files are not guaranteed to be\n" +
                                  "locked.")

        def maxconnections_hint(self, ref = self):
            ref.hinttext.SetLabel('\n\nSome operating systems, most\n' +
                                  'notably Windows 9x/ME combined\n' +
                                  'with certain network drivers,\n' +
                                  "cannot handle more than a certain\n" +
                                  "number of open ports.  If the\n" +
                                  "client freezes, try setting this\n" +
                                  "to 60 or below.")

        EVT_BUTTON(self.advancedMenuBox, okButton.GetId(), saveConfigs)
        EVT_BUTTON(self.advancedMenuBox, cancelButton.GetId(), cancelConfigs)
        EVT_ENTER_WINDOW(ip_data, ip_hint)
        EVT_ENTER_WINDOW(bind_data, bind_hint)
        EVT_ENTER_WINDOW(minpeers_data, minpeers_hint)
        EVT_ENTER_WINDOW(alloctype_data, alloctype_hint)
        EVT_ENTER_WINDOW(allocrate_data, allocrate_hint)
        EVT_ENTER_WINDOW(maxfilesopen_data, maxfilesopen_hint)
        EVT_ENTER_WINDOW(maxconnections_data, maxconnections_hint)

        self.advancedMenuBox.Show ()
        border.Fit(panel)
        self.advancedMenuBox.Fit()
       
        

        
    def onNumSimSpin(self, event):
        val = event.GetPosition()
        if val == 0:
            self.numsimtext.SetValue("Unlimited")
        else:
            self.numsimtext.SetValue(str(val))

    def onBrowseDir(self, event):
        foldername = wxDirDialog(self.parent, 'Choose a default folder for download files', 
                                 style = wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON)
        if foldername.ShowModal() == wxID_OK:
            self.dir.SetValue(foldername.GetPath())

    def onApply(self, event):
        # Set new value to abcparams
        ##############################
        self.parent.abcparams['minport']       = self.minport.GetValue()
        self.parent.abcparams['maxport']       = self.maxport.GetValue()
        if self.numsimtext.GetValue() == "Unlimited":
            self.parent.abcparams['numsimdownload'] = "0"
        else:
            self.parent.abcparams['numsimdownload'] = self.numsimtext.GetValue()

        if self.torrentbackup.GetValue():
            self.parent.abcparams['removetorrent'] = "1"
        else:
            self.parent.abcparams['removetorrent'] = "0"

        if self.defaultdir.GetValue():
            self.parent.abcparams['setdefaultfolder'] = "1"
        else:
            self.parent.abcparams['setdefaultfolder'] = "0"
        self.parent.abcparams['defaultfolder'] = self.dir.GetValue()
        
        if self.mintray.GetValue():
            self.parent.abcparams['mintray'] = "1"
        else:
            self.parent.abcparams['mintray'] = "0"

        # Saving Value to abc.conf
        ##############################
        abcconfig = TorrentConfigFileManager()
        abcconfig.open(path.join(self.parent.abcpath,"abc.conf"), "w")
        abcconfig.writeConfig("minport",         self.parent.abcparams['minport'])
        abcconfig.writeConfig("maxport",         self.parent.abcparams['maxport'])
        abcconfig.writeConfig("maxupload",       self.parent.abcparams['maxupload'])
        abcconfig.writeConfig("maxuploadrate",   self.parent.abcparams['maxuploadrate'])
        abcconfig.writeConfig("numsimdownload",  self.parent.abcparams['numsimdownload'])
        abcconfig.writeConfig("uploadoption",    self.parent.abcparams['uploadoption'])
        abcconfig.writeConfig("uploadtimeh",     self.parent.abcparams['uploadtimeh'])
        abcconfig.writeConfig("uploadtimem",     self.parent.abcparams['uploadtimem'])
        abcconfig.writeConfig("uploadratio",     self.parent.abcparams['uploadratio'])
        abcconfig.writeConfig("removetorrent",   self.parent.abcparams['removetorrent'])
        abcconfig.writeConfig("setdefaultfolder",self.parent.abcparams['setdefaultfolder'])
        abcconfig.writeConfig("defaultfolder",   self.parent.abcparams['defaultfolder'])
        abcconfig.writeConfig("mintray",         self.parent.abcparams['mintray'])

        # Advanced Options
        if len(self.advancedConfig) != 0:
            abcconfig.writeConfig("ip",              self.advancedConfig['ip'])
            abcconfig.writeConfig("bind",            self.advancedConfig['bind'])
            abcconfig.writeConfig("min_peers",       str(self.advancedConfig['min_peers']))
            abcconfig.writeConfig("max_initiate",    str(self.advancedConfig['max_initiate']))
            abcconfig.writeConfig("alloc_type",      self.advancedConfig['alloc_type'])
            abcconfig.writeConfig("alloc_rate",      str(self.advancedConfig['alloc_rate']))
            abcconfig.writeConfig("max_files_open",  str(self.advancedConfig['max_files_open']))
            abcconfig.writeConfig("max_connections", str(self.advancedConfig['max_connections']))

            self.parent.abcparams['ip']              = self.advancedConfig['ip']
            self.parent.abcparams['bind']            = self.advancedConfig['bind']
            self.parent.abcparams['min_peers']       = str(self.advancedConfig['min_peers'])
            self.parent.abcparams['max_initiate']    = str(self.advancedConfig['max_initiate'])
            self.parent.abcparams['alloc_type']      = self.advancedConfig['alloc_type']
            self.parent.abcparams['alloc_rate']      = str(self.advancedConfig['alloc_rate'])
            self.parent.abcparams['max_files_open']  = str(self.advancedConfig['max_files_open'])
            self.parent.abcparams['max_connections'] = str(self.advancedConfig['max_connections'])
            
        else:
            abcconfig.writeConfig("ip",              self.parent.abcparams['ip'])
            abcconfig.writeConfig("bind",            self.parent.abcparams['bind'])
            abcconfig.writeConfig("min_peers",       self.parent.abcparams['min_peers'])
            abcconfig.writeConfig("max_initiate",    self.parent.abcparams['max_initiate'])
            abcconfig.writeConfig("alloc_type",      self.parent.abcparams['alloc_type'])
            abcconfig.writeConfig("alloc_rate",      self.parent.abcparams['alloc_rate'])
            abcconfig.writeConfig("max_files_open",  self.parent.abcparams['max_files_open'])
            abcconfig.writeConfig("max_connections", self.parent.abcparams['max_connections'])

        abcconfig.close()
        
        self.parent.window.changeABCParams(self.parent.abcparams)    #overwrite flag

        if (self.advancedMenuBox is not None):
            try:
                self.advancedMenuBox.Close ()
            except wxPyDeadObjectError, e:
                self.advancedMenuBox = None

        self.Destroy()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -