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

📄 abcoption.py

📁 ABC-win32-v3.1 一个P2P软源代码
💻 PY
📖 第 1 页 / 共 5 页
字号:
        percent_sizer.Add(wx.StaticText(self, -1, "%"), 0, wx.ALIGN_CENTER_VERTICAL)
        
        continuesection.Add(percent_sizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        sizer.Add(continuesection, 0, wx.EXPAND|wx.ALL, 5)
        
        self.initTasks()

    def loadValues(self, Read = None):
        if Read is None:
            Read = self.utility.config.Read

        self.cbratio.SetValue(Read('uploadratio'))
        self.cbhtime.SetValue(Read('uploadtimeh'))
        self.cbmtime.SetValue(Read('uploadtimem'))
            
        self.rb[Read('uploadoption', "int")].SetValue(True)
        
    def apply(self):
        # Set new value to parameters
        ##############################
        for i in range (3):
            if self.rb[i].GetValue():
                self.utility.config.Write('uploadoption', i)

        self.utility.config.Write('uploadtimeh', self.cbhtime.GetValue())
        self.utility.config.Write('uploadtimem', self.cbmtime.GetValue())
        self.utility.config.Write('uploadratio', self.cbratio.GetValue())


################################################################
#
# Class: ColorPanel
#
# Contains settings for what the colors for different torrent
# statuses should be.
#
################################################################
class ColorPanel(ABCOptionPanel):
    def __init__(self, parent, dialog):
        ABCOptionPanel.__init__(self, parent, dialog)
        sizer = self.sizer
        
        self.colors = ['color_startup', 
                       'color_disconnected', 
                       'color_noconnections', 
                       'color_noincoming', 
                       'color_nocomplete', 
                       'color_good' ]
        color_boxes = {}
        color_text = {}
        self.color_buttons = {}
        
        # Striped list options
        for color in self.colors:
            color_boxes[color] = wx.BoxSizer(wx.HORIZONTAL)

            self.color_buttons[color] = colourselect.ColourSelect(self, -1, "", size = (60, 20))       
            color_boxes[color].Add(self.color_buttons[color], 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 5)
        
            color_text[color] = wx.StaticText(self, -1, self.utility.lang.get(color))
            color_boxes[color].Add(color_text[color], 0, wx.ALIGN_CENTER_VERTICAL)
               
            sizer.Add(color_boxes[color], 0, wx.ALIGN_LEFT|wx.ALL, 5)

        self.initTasks()

    def loadValues(self, Read = None):
        if Read is None:
            Read = self.utility.config.Read
        
        for color in self.colors:
            self.color_buttons[color].SetValue(Read(color, "color"))
        
    def apply(self):
        overallchange = False
        
        for color in self.colors:
            color_value = self.color_buttons[color].GetColour()
            changed = self.utility.config.Write(color, color_value, "color")
            if changed:
                overallchange = True

        if overallchange:
            for ABCTorrentTemp in self.utility.torrents["all"]:
                ABCTorrentTemp.updateColor()


################################################################
#
# Class: AdvancedNetworkPanel
#
# Contains advanced network settings
# (defaults should be fine for most users)
#
################################################################
class AdvancedNetworkPanel(ABCOptionPanel):
    def __init__(self, parent, dialog):
        ABCOptionPanel.__init__(self, parent, dialog)
        sizer = self.sizer

        warningtext = wx.StaticText(self, -1, self.utility.lang.get('changeownrisk'))
        sizer.Add(warningtext, 0, wx.ALIGN_CENTER|wx.ALL, 5)
       
        #self.ipv6bindsv4_data=wx.Choice(self, -1,
        #                 choices = ['separate sockets', 'single socket'])
        #self.ipv6bindsv4_data.SetSelection(int(self.advancedConfig['ipv6_binds_v4']))
        
        datasizer = wx.FlexGridSizer(cols = 2, vgap = 5, hgap = 10)

        # Local IP
        self.ip_data = wx.TextCtrl(self, -1)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('localip')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.ip_data)

        # IP to Bind to
        self.bind_data = wx.TextCtrl(self, -1)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('iptobindto')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.bind_data)

        # Minimum Peers
        self.minpeers_data = wx.SpinCtrl(self, size = wx.Size(60, -1))
        self.minpeers_data.SetRange(10, 100)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('minnumberofpeer')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.minpeers_data)

        # Maximum Connections
        self.maxconnections_choices = [self.utility.lang.get('nolimit'), '20', '30', '40', '60', '100', '200']
        self.maxconnections_data=wx.Choice(self, -1, wx.Point(-1, -1), wx.Size(-1, -1), self.maxconnections_choices)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('maxpeerconnection')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.maxconnections_data)
        
        # UPnP Settings
        self.upnp_choices = [ self.utility.lang.get('upnp_0'), 
                         self.utility.lang.get('upnp_1'), 
                         self.utility.lang.get('upnp_2') ]
        self.upnp_data = wx.ComboBox(self, -1, "", wx.Point(-1, -1), wx.Size(-1, -1), self.upnp_choices, wx.CB_DROPDOWN|wx.CB_READONLY)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('upnp')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.upnp_data)

        sizer.Add(datasizer, 0, wx.ALL, 5)
        
        # Set tooltips
        self.ip_data.SetToolTipString(self.utility.lang.get('iphint'))
        self.bind_data.SetToolTipString(self.utility.lang.get('bindhint'))
        self.minpeers_data.SetToolTipString(self.utility.lang.get('minpeershint'))
        self.maxconnections_data.SetToolTipString(self.utility.lang.get('maxconnectionhint'))
               
        self.initTasks()

    def loadValues(self, Read = None):
        if Read is None:
            Read = self.utility.config.Read
        
        self.ip_data.SetValue(Read('ip'))
        self.bind_data.SetValue(Read('bind'))
        
        self.minpeers_data.SetValue(Read('min_peers', "int"))
        
        setval = Read('max_connections', "int")
        if setval == 0:
            setval = self.utility.lang.get('nolimit')
        else:
            setval = str(setval)
        if not setval in self.maxconnections_choices:
            setval = self.maxconnections_choices[0]
        self.maxconnections_data.SetStringSelection(setval)
        
        upnp_val = self.utility.config.Read('upnp_nat_access', "int")
        if upnp_val >= len(self.upnp_choices):
            upnp_val = len(self.upnp_choices) - 1
        self.upnp_data.SetStringSelection(self.upnp_choices[upnp_val])

#        #self.ipv6bindsv4_data.SetSelection()
        
    def apply(self):
        #if self.ipv6.GetValue():
        #    self.utility.config.Write('ipv6') = "1"
        #else:
        #    self.utility.config.Write('ipv6') = "0"
        self.utility.config.Write('ipv6', "0")
        
                # Advanced Options
        self.utility.config.Write('ip', self.ip_data.GetValue())
        self.utility.config.Write('bind', self.bind_data.GetValue())
        
        minpeers = self.minpeers_data.GetValue()
        self.utility.config.Write('min_peers', minpeers)

        try:
            maxconnections = int(self.maxconnections_data.GetStringSelection())
            maxinitiate = min(2 * minpeers, maxconnections)
        except:       # if it ain't a number, it must be "no limit"
            maxconnections = 0
            maxinitiate = 2 * minpeers

        self.utility.config.Write('max_initiate', maxinitiate)
        self.utility.config.Write('max_connections', maxconnections)
        
        upnp_choices = [ self.utility.lang.get('upnp_0'), 
                         self.utility.lang.get('upnp_1'), 
                         self.utility.lang.get('upnp_2') ]
        selected = upnp_choices.index(self.upnp_data.GetValue())
        self.utility.config.Write('upnp_nat_access', selected)

        self.utility.config.Write('ipv6_binds_v4', "1")


################################################################
#
# Class: AdvancedDiskPanel
#
# Contains advanced settings controlling how data is written to
# and read from disk.
# (defaults should be fine for most users)
#
################################################################
class AdvancedDiskPanel(ABCOptionPanel):
    def __init__(self, parent, dialog):
        ABCOptionPanel.__init__(self, parent, dialog)
        sizer = self.sizer

        warningtext = wx.StaticText(self, -1, self.utility.lang.get('changeownrisk'))
        sizer.Add(warningtext, 0, wx.ALIGN_CENTER|wx.ALL, 5)
       
        datasizer = wx.FlexGridSizer(cols = 2, vgap = 5, hgap = 10)

        # Allocation Type
        
        alloc_choices = [self.utility.lang.get('alloc_normal'), 
                         self.utility.lang.get('alloc_background'), 
                         self.utility.lang.get('alloc_prealloc'), 
                         self.utility.lang.get('alloc_sparse')]
        self.alloc_strings = {"normal": 0, "background": 1, "pre-allocate": 2, "sparse": 3}
        self.alloctype_data=wx.Choice(self, -1, wx.Point(-1, -1), wx.Size(-1, -1), alloc_choices)

        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('diskalloctype')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.alloctype_data)

        # Allocation Rate
        self.allocrate_data = wx.SpinCtrl(self, size = wx.Size(60, -1))
        self.allocrate_data.SetRange(1, 100)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('allocrate')), 1, wx.ALIGN_CENTER_VERTICAL)
        
        allocrate_box = wx.BoxSizer(wx.HORIZONTAL)
        allocrate_box.Add(self.allocrate_data)
        allocrate_box.Add(wx.StaticText(self, -1, " " + self.utility.lang.get('mb') + "/" + self.utility.lang.get("l_second")), 1, wx.ALIGN_CENTER_VERTICAL)
        
        datasizer.Add(allocrate_box)

        # Locking Method
        locking_choices = [self.utility.lang.get('lock_never'), 
                           self.utility.lang.get('lock_writing'), 
                           self.utility.lang.get('lock_always')]
        self.locking_data=wx.Choice(self, -1, wx.Point(-1, -1), wx.Size(-1, -1), locking_choices)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('filelocking')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.locking_data)

        # Doublecheck Method
        doublecheck_choices = [self.utility.lang.get('check_none'), 
                               self.utility.lang.get('check_double'), 
                               self.utility.lang.get('check_triple')]
        self.doublecheck_data=wx.Choice(self, -1, wx.Point(-1, -1), wx.Size(-1, -1), doublecheck_choices)
        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('extradatachecking')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.doublecheck_data)

        # Maximum Files Open
        self.maxfilesopen_choices = ['50', '100', '200', self.utility.lang.get('nolimit')]
        self.maxfilesopen_data=wx.Choice(self, -1, wx.Point(-1, -1), wx.Size(-1, -1), self.maxfilesopen_choices)

        datasizer.Add(wx.StaticText(self, -1, self.utility.lang.get('maxfileopen')), 1, wx.ALIGN_CENTER_VERTICAL)
        datasizer.Add(self.maxfilesopen_data)        
      
        # Flush data        
        self.flush_data_enable = wx.CheckBox(self, -1, self.utility.lang.get('flush_data'))

        self.flush_data = wx.SpinCtrl(self, size = wx.Size(60, -1))
        self.flush_data.SetRange(0, 999)
        
        datasizer.Add(self.flush_data_enable, 0, wx.ALIGN_CENTER_VERTICAL)

        flush_box = wx.BoxSizer(wx.HORIZONTAL)
        flush_box.Add(self.flush_data, 0, wx.ALIGN_CENTER_VERTICAL)
        flush_box.Add(wx.StaticText(self, -1, self.utility.lang.get('minute_long')), 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)

        datasizer.Add(flush_box)

        sizer.Add(datasizer, 0, wx.ALL, 5)

        # Disk buffering
        buffer_title = wx.StaticBox(self, -1, self.utility.lang.get('bufferdisk'))
        buffer = wx.StaticBoxSizer(buffer_title, wx.VERTICAL)

⌨️ 快捷键说明

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