コード例 #1
0
    def AddComponents(self, leftSpacer, rightSpacer):
        if leftSpacer > 0:
            self.hSizer.AddSpacer((leftSpacer, -1))
         
        for i in xrange(len(self.columns)):
            if self.columns[i]['width'] == wx.LIST_AUTOSIZE:
                option = 1
                size = wx.DefaultSize
            else:
                option = 0
                size = (self.columns[i]['width'],-1)
                
            type = self.columns[i].get('type', 'label')
            if type == 'label':
                str_data = self.columns[i].get('fmt', unicode)(self.data[i])
                control = StaticText(self, style=self.columns[i].get('style',0)|wx.ST_NO_AUTORESIZE|wx.ST_DOTS_END, size=size)

                fontWeight = self.columns[i].get('fontWeight', wx.FONTWEIGHT_NORMAL)
                if fontWeight != wx.FONTWEIGHT_NORMAL:
                    _set_font(control, fontweight = fontWeight)

                #niels: wx magic prevents us from passing this string with the constructor, ampersands will not work
                control.SetLabel(str_data.replace('&', "&&"))
                
            elif type == 'method':
                control = self.columns[i]['method'](self, self)
                
            if control:
                control.icon = self._get_icon(i, 'icon')
                control.icon_right = self._get_icon(i, 'icon_right')
                self.controls.append(control)
                
                
                if i != 0:
                    self.hSizer.AddSpacer((3, -1))
                    
                if control.icon:
                    self.hSizer.Add(control.icon, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 3)
                
                self.hSizer.Add(control, option, wx.RESERVE_SPACE_EVEN_IF_HIDDEN|wx.ALIGN_CENTER_VERTICAL|wx.TOP|wx.BOTTOM, 3)
                
                if control.icon_right:
                    self.hSizer.Add(control.icon_right, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 3)
                
                if self.columns[i]['width'] == wx.LIST_AUTOSIZE:
                    control.SetMinSize((1,-1))
                
                elif self.columns[i]['width'] == LIST_AUTOSIZEHEADER:
                    self.columns[i]['width'] = control.GetSize()[0]
                    if self.parent_list.parent_list.header:
                        self.parent_list.parent_list.header.ResizeColumn(i, self.columns[i]['width'])  
            else:
                if self.columns[i]['width'] != LIST_AUTOSIZEHEADER:
                    self.hSizer.Add((self.columns[i]['width'], -1), 0, wx.LEFT, 3)    

        if rightSpacer > 0:
            self.hSizer.AddSpacer((rightSpacer, -1))
        self.hSizer.Layout()
        
        self.AddEvents(self)
コード例 #2
0
ファイル: home.py プロジェクト: ebcayabyab-personal/swiftarm
 def addColumn(key):
     strkey = key.replace("_", " ").capitalize()
     header = StaticText(self.panel, -1, strkey)
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     self.gridSizer.Add(header)
     self.textdict[key] = StaticText(self.panel, -1, '')
     self.gridSizer.Add(self.textdict[key])
コード例 #3
0
ファイル: home.py プロジェクト: ebcabaybay/swiftarm
 def addColumn(key):
     strkey = key.replace("_", " ").capitalize()
     header = StaticText(self.panel, -1, strkey)
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     self.gridSizer.Add(header)
     self.textdict[key] = StaticText(self.panel, -1, '')
     self.gridSizer.Add(self.textdict[key])
コード例 #4
0
 def __init__(self, parent, torrent):
     canEdit = canComment = False
     if torrent.hasChannel():
         state, iamModerator = torrent.channel.getState()
         canEdit = state >= ChannelCommunity.CHANNEL_OPEN
     
     height = 125
     if canEdit:
         height = 200
     
     wx.Dialog.__init__(self, parent, -1, 'Are you sure you want to remove this torrent?', size=(600, height))
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     hSizer.Add(wx.StaticBitmap(self, -1, wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_MESSAGE_BOX)), 0, wx.RIGHT, 10)
     
     vSizer = wx.BoxSizer(wx.VERTICAL)
     firstLine = StaticText(self, -1, "Delete '%s' from disk, or just remove them from your downloads?"%torrent.name)
     _set_font(firstLine, fontweight = wx.FONTWEIGHT_BOLD)
     firstLine.SetMinSize((1, -1))
     
     vSizer.Add(firstLine, 0, wx.EXPAND|wx.BOTTOM, 3)
     vSizer.Add(StaticText(self, -1, "Removing from disk will move the selected item to your trash."), 0, wx.EXPAND)
     
     vSizer.AddStretchSpacer()
     
     self.newName = None
     if canEdit:
         vSizer.Add(StaticText(self, -1, "While we're at it, can you improve the name of this torrent?"), 0, wx.EXPAND|wx.BOTTOM, 3)
         self.newName = EditText(self, torrent.name)
         vSizer.Add(self.newName, 0, wx.EXPAND)
         vSizer.AddStretchSpacer()
     
     bSizer = wx.BoxSizer(wx.HORIZONTAL)
     bSizer.AddStretchSpacer()
     
     bSizer.Add(wx.Button(self, wx.ID_CANCEL), 0, wx.RIGHT, 3)
     bSizer.Add(wx.Button(self, wx.ID_DEFAULT, 'Only delete from downloads'), 0, wx.RIGHT, 3)
     bSizer.Add(wx.Button(self, wx.ID_DELETE, 'Also delete from disk'))
     
     vSizer.Add(bSizer, 0, wx.ALIGN_RIGHT|wx.TOP, 7)
     hSizer.Add(vSizer, 1, wx.EXPAND)
     
     border = wx.BoxSizer()
     border.Add(hSizer, 1, wx.ALL|wx.EXPAND, 10)
     
     self.Bind(wx.EVT_BUTTON, lambda event: self.EndModal(event.GetId()))
     self.SetSizer(border)
     self.Layout()
     self.CenterOnParent()
コード例 #5
0
    def AddComponents(self, columns, spacers):
        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.AddSpacer((-1, 3))

        self.title = StaticText(self)
        _set_font(self.title, self.font_increment, self.fontweight)

        titlePanel = self.GetTitlePanel(self)
        subtitlePanel = self.GetSubTitlePanel(self)
        righttitlePanel = self.GetRightTitlePanel(self)
        belowPanel = self.GetBelowPanel(self)

        if titlePanel:
            subSizer = wx.BoxSizer(wx.HORIZONTAL)
            subSizer.Add(self.title)
            subSizer.Add(titlePanel, 0, wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 3)
            titlePanel = subSizer
        else:
            titlePanel = self.title

        if subtitlePanel:
            subSizer = wx.BoxSizer(wx.VERTICAL)
            subSizer.Add(titlePanel, 0, wx.BOTTOM, 3)
            subSizer.Add(subtitlePanel)
            subtitlePanel = subSizer
        else:
            subtitlePanel = titlePanel

        subSizer = wx.BoxSizer(wx.HORIZONTAL)
        subSizer.Add(subtitlePanel)
        if righttitlePanel:
            subSizer.Add(righttitlePanel, 1, wx.LEFT, 3)
        righttitlePanel = subSizer

        vSizer.Add(righttitlePanel, 0, wx.EXPAND | wx.LEFT | wx.RIGHT,
                   self.radius + spacers[0])
        if belowPanel:
            vSizer.Add(belowPanel, 1, wx.EXPAND | wx.TOP, 3)

        vSizer.AddSpacer((-1, 3))

        if len(columns) > 0:
            hSizer = wx.BoxSizer(wx.HORIZONTAL)
            self.AddColumns(hSizer, self, columns)
            vSizer.Add(hSizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT,
                       self.radius + spacers[0])
        self.SetSizer(vSizer)
コード例 #6
0
    def AddComponents(self, columns, spacers):
        vSizer = wx.BoxSizer(wx.VERTICAL)
        vSizer.AddSpacer((-1, 3))
        
        self.title = StaticText(self)
        _set_font(self.title, self.font_increment, self.fontweight)
                
        titlePanel = self.GetTitlePanel(self)
        subtitlePanel = self.GetSubTitlePanel(self)
        righttitlePanel = self.GetRightTitlePanel(self)
        belowPanel = self.GetBelowPanel(self)
        
        if titlePanel:
            subSizer = wx.BoxSizer(wx.HORIZONTAL)
            subSizer.Add(self.title)
            subSizer.Add(titlePanel, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, 3)
            titlePanel = subSizer
        else:
            titlePanel = self.title

        if subtitlePanel:
            subSizer = wx.BoxSizer(wx.VERTICAL)
            subSizer.Add(titlePanel, 0, wx.BOTTOM, 3)
            subSizer.Add(subtitlePanel)
            subtitlePanel = subSizer
        else:
            subtitlePanel = titlePanel
        
        subSizer = wx.BoxSizer(wx.HORIZONTAL)
        subSizer.Add(subtitlePanel)
        if righttitlePanel:
            subSizer.Add(righttitlePanel, 1, wx.LEFT, 3)
        righttitlePanel = subSizer
             
        vSizer.Add(righttitlePanel, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, self.radius+spacers[0])
        if belowPanel:
            vSizer.Add(belowPanel, 1, wx.EXPAND|wx.TOP, 3)

        vSizer.AddSpacer((-1, 3))

        if len(columns) > 0:
            hSizer = wx.BoxSizer(wx.HORIZONTAL)
            self.AddColumns(hSizer, self, columns)
            vSizer.Add(hSizer, 0, wx.EXPAND|wx.LEFT|wx.RIGHT, self.radius+spacers[0])
        self.SetSizer(vSizer)
コード例 #7
0
ファイル: CreateTorrent.py プロジェクト: ebcabaybay/swiftarm
    def __init__(self,
                 parent,
                 configfile,
                 fileconfigfile,
                 suggestedTrackers,
                 toChannel=False):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           'Create a .torrent',
                           size=(600, 200))
        self.guiutility = GUIUtility.getInstance()
        self.toChannel = toChannel

        vSizer = wx.BoxSizer(wx.VERTICAL)

        header = wx.StaticText(self, -1, 'Browse for a file or files')
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.locationText = StaticText(self, -1, '')
        vSizer.Add(self.locationText, 0, wx.EXPAND | wx.BOTTOM, 3)

        browseButton = wx.Button(self, -1, 'Browse')
        browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)

        browseDirButton = wx.Button(self, -1, 'Browse for a Directory')
        browseDirButton.Bind(wx.EVT_BUTTON, self.OnBrowseDir)

        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(browseButton)
        hSizer.Add(browseDirButton)
        vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 3)

        #self.recursive = wx.CheckBox(self, -1, 'Include all subdirectories')
        #self.recursive.Bind(wx.EVT_CHECKBOX, self.OnRecursive)
        #vSizer.Add(self.recursive, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)

        vSizer.Add(wx.StaticLine(self, -1), 0,
                   wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        header = wx.StaticText(self, -1, '.Torrent details')
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.foundFilesText = StaticText(
            self, -1, 'Please select a file or files first')
        vSizer.Add(self.foundFilesText, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.combineRadio = wx.RadioButton(
            self,
            -1,
            'Combine files into a single .torrent',
            style=wx.RB_GROUP)
        self.combineRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine)
        self.combineRadio.Enable(False)

        self.sepRadio = wx.RadioButton(
            self, -1, 'Create separate .torrent for every file')
        self.sepRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine)
        self.sepRadio.Enable(False)

        vSizer.Add(self.combineRadio, 0, wx.EXPAND | wx.BOTTOM, 3)
        vSizer.Add(self.sepRadio, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.specifiedName = wx.TextCtrl(self, -1, '')
        self.specifiedName.Enable(False)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(wx.StaticText(self, -1, 'Specify a name'), 0,
                   wx.ALIGN_CENTER_VERTICAL)
        hSizer.Add(self.specifiedName, 1, wx.EXPAND)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, 'Trackers'))
        self.trackerList = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        self.trackerList.SetMinSize((500, -1))

        self.trackerHistory = wx.FileHistory(10)
        self.config = wx.FileConfig(appName="Tribler",
                                    localFilename=configfile)
        self.trackerHistory.Load(self.config)

        if self.trackerHistory.GetCount() > 0:
            trackers = [
                self.trackerHistory.GetHistoryFile(i)
                for i in range(self.trackerHistory.GetCount())
            ]
            if len(trackers) < len(suggestedTrackers):
                trackers.extend(suggestedTrackers[:len(suggestedTrackers) -
                                                  len(trackers)])
        else:
            trackers = suggestedTrackers

        for tracker in trackers:
            self.trackerList.AppendText(tracker + "\n")

        vSizer.Add(self.trackerList, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, 'Comment'))
        self.commentList = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        vSizer.Add(self.commentList, 0, wx.EXPAND, 3)

        vSizer.Add(wx.StaticLine(self, -1), 0,
                   wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10)

        header = wx.StaticText(self, -1, 'Advanced options')
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 3)

        abbrev_mb = " " + self.guiutility.utility.lang.get('MB')
        abbrev_kb = " " + self.guiutility.utility.lang.get('KB')
        piece_choices = [
            self.guiutility.utility.lang.get('automatic'), '4' + abbrev_mb,
            '2' + abbrev_mb, '1' + abbrev_mb, '512' + abbrev_kb,
            '256' + abbrev_kb, '128' + abbrev_kb, '64' + abbrev_kb,
            '32' + abbrev_kb
        ]
        self.pieceChoice = wx.Choice(self, -1, choices=piece_choices)
        self.pieceChoice.SetSelection(0)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(StaticText(self, -1, 'Piecesize'), 1)
        hSizer.Add(self.pieceChoice)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, 'Webseed'))
        self.webSeed = wx.TextCtrl(self, -1,
                                   'Please select a file or files first')
        self.webSeed.Enable(False)
        vSizer.Add(self.webSeed, 0, wx.EXPAND | wx.BOTTOM, 3)

        cancel = wx.Button(self, wx.ID_CANCEL)
        cancel.Bind(wx.EVT_BUTTON, self.OnCancel)

        create = wx.Button(self, wx.ID_OK, 'Create .torrent(s)')
        create.Bind(wx.EVT_BUTTON, self.OnOk)

        bSizer = wx.StdDialogButtonSizer()
        bSizer.AddButton(cancel)
        bSizer.AddButton(create)
        bSizer.Realize()
        vSizer.Add(bSizer, 0, wx.EXPAND)

        sizer = wx.BoxSizer()
        sizer.Add(vSizer, 1, wx.EXPAND | wx.ALL, 10)
        self.SetSizerAndFit(sizer)

        self.selectedPaths = []
        self.createdTorrents = []
        self.cancelEvent = Event()

        self.filehistory = wx.FileHistory(1)
        self.fileconfig = wx.FileConfig(appName="Tribler",
                                        localFilename=fileconfigfile)
        self.filehistory.Load(self.fileconfig)

        if self.filehistory.GetCount() > 0:
            self.latestFile = self.filehistory.GetHistoryFile(0)
        else:
            self.latestFile = ''
        self.paths = None
コード例 #8
0
ファイル: SaveAs.py プロジェクト: ebcabaybay/swiftarm
 def __init__(self, parent, tdef, defaultdir, defaultname, configfile, selectedFiles = None):
     wx.Dialog.__init__(self, parent, -1, 'Please specify a target directory', size=(600,450))
     
     self.filehistory = wx.FileHistory(10)
     self.config = wx.FileConfig(appName = "Tribler", localFilename = configfile)
     self.filehistory.Load(self.config)
     self.defaultdir = defaultdir
     self.guiutility = GUIUtility.getInstance()
     self.listCtrl = None
     
     if self.filehistory.GetCount() > 0:
         lastUsed = self.filehistory.GetHistoryFile(0)
     else:
         lastUsed = defaultdir
     
     vSizer = wx.BoxSizer(wx.VERTICAL)
     
     if tdef:
         line = 'Please select a directory where to save:'
     else:
         line = 'Please select a directory where to save this torrent'
         
     firstLine = wx.StaticText(self, -1, line)
     _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(firstLine, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     if tdef:
         torrentName = wx.StaticText(self, -1, tdef.get_name_as_unicode())
         torrentName.SetMinSize((1, -1))
         vSizer.Add(torrentName, 0, wx.EXPAND|wx.BOTTOM|wx.RIGHT, 3)
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     hSizer.Add(wx.StaticText(self, -1, 'Save as:'), 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.BOTTOM, 3)
     
     choices = [self.filehistory.GetHistoryFile(i) for i in range(self.filehistory.GetCount())]
     if defaultdir not in choices:
         choices.append(defaultdir)
         
     
     if defaultname:
         choices.insert(0, os.path.join(lastUsed, defaultname))
         self.dirTextCtrl = wx.ComboBox(self, -1, os.path.join(lastUsed, defaultname), choices = choices, style = wx.CB_DROPDOWN)
     else:
         self.dirTextCtrl = wx.ComboBox(self, -1, lastUsed, choices = choices, style = wx.CB_DROPDOWN)
     self.dirTextCtrl.Select(0)
         
     hSizer.Add(self.dirTextCtrl, 1, wx.EXPAND|wx.RIGHT|wx.BOTTOM, 3)
     
     browseButton = wx.Button(self, -1, 'Browse')
     browseButton.Bind(wx.EVT_BUTTON, self.OnBrowseDir)
     hSizer.Add(browseButton)
     
     vSizer.Add(hSizer, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     if tdef:
         vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 10)
         
         firstLine = wx.StaticText(self, -1, "Content:")
         _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD)
         vSizer.Add(firstLine, 0, wx.BOTTOM, 3)
         
         vSizer.Add(wx.StaticText(self, -1, 'Use the checkboxes to choose which files to download.\nUse ctrl+a to select all/deselect all.'), 0, wx.BOTTOM, 3)
         
         self.listCtrl = CheckSelectableListCtrl(self)
         self.listCtrl.InsertColumn(0, 'Name')
         self.listCtrl.InsertColumn(1, 'Size', wx.LIST_FORMAT_RIGHT)
         
         #Add files
         def sort_by_size(a, b):
             return cmp(a[1],b[1])
         
         files = tdef.get_files_as_unicode_with_length()
         files.sort(sort_by_size, reverse = True)
         
         for filename, size in files:
             try:
                 pos = self.listCtrl.InsertStringItem(sys.maxint, filename)
             except:
                 try:
                     pos = self.listCtrl.InsertStringItem(sys.maxint, filename.decode('utf-8','ignore'))
                 except:
                     print >> sys.stderr, "Could not format filename", self.torrent.name
             self.listCtrl.SetItemData(pos, pos)
             self.listCtrl.SetStringItem(pos, 1, self.guiutility.utility.size_format(size))
             
             if selectedFiles:
                 self.listCtrl.CheckItem(pos, filename in selectedFiles)
         
         if selectedFiles == None:
             self.listCtrl.doSelectAll()
         
         self.listCtrl.setResizeColumn(0)
         self.listCtrl.SetColumnWidth(1, wx.LIST_AUTOSIZE) #autosize only works after adding rows
         vSizer.Add(self.listCtrl, 1, wx.EXPAND|wx.BOTTOM, 3)
     
     cancel = wx.Button(self, wx.ID_CANCEL)
     cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
     
     ok = wx.Button(self, wx.ID_OK)
     ok.Bind(wx.EVT_BUTTON, self.OnOk)
     
     bSizer = wx.StdDialogButtonSizer()
     bSizer.AddButton(cancel)
     bSizer.AddButton(ok)
     bSizer.Realize()
     vSizer.Add(bSizer, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     sizer = wx.BoxSizer()
     sizer.Add(vSizer, 1, wx.EXPAND|wx.ALL, 10)
     self.SetSizer(sizer)
コード例 #9
0
 def __init__(self, parent, configfile, suggestedTrackers, toChannel = False):
     wx.Dialog.__init__(self, parent, -1, 'Create a .torrent', size=(500,200))
     self.guiutility = GUIUtility.getInstance()
     self.toChannel = toChannel
     
     vSizer = wx.BoxSizer(wx.VERTICAL)
     
     header = wx.StaticText(self, -1, 'Browse for a file or files')
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     self.locationText = StaticText(self, -1, '')
     vSizer.Add(self.locationText, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     browseButton = wx.Button(self, -1, 'Browse')
     browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)
     
     browseDirButton = wx.Button(self, -1, 'Browse for a Directory')
     browseDirButton.Bind(wx.EVT_BUTTON, self.OnBrowseDir)
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     hSizer.Add(browseButton)
     hSizer.Add(browseDirButton)
     vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)
     
     vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
     
     header = wx.StaticText(self, -1, '.Torrent details')
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     self.foundFilesText = StaticText(self, -1, 'No files selected yet')
     vSizer.Add(self.foundFilesText, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     self.combineRadio = wx.RadioButton(self, -1, 'Combine files into a single .torrent', style = wx.RB_GROUP)
     self.sepRadio = wx.RadioButton(self, -1, 'Create separate .torrent for every file')
     vSizer.Add(self.combineRadio, 0, wx.EXPAND|wx.BOTTOM, 3)
     vSizer.Add(self.sepRadio, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     vSizer.Add(StaticText(self, -1, 'Trackers'))
     self.trackerList = wx.TextCtrl(self, -1, '', style = wx.TE_MULTILINE)
     self.trackerList.SetMinSize((500, -1))
     
     self.trackerHistory = wx.FileHistory(10)
     self.config = wx.FileConfig(appName = "Tribler", localFilename = configfile)
     self.trackerHistory.Load(self.config)
     
     if self.trackerHistory.GetCount() > 0:
         trackers = [self.trackerHistory.GetHistoryFile(i) for i in range(self.trackerHistory.GetCount())]
         if len(trackers) < len(suggestedTrackers):
             trackers.extend(suggestedTrackers[:len(suggestedTrackers)-len(trackers)])
     else:
         trackers = suggestedTrackers
         
     for tracker in trackers:
         self.trackerList.AppendText(tracker + "\n")
         
     vSizer.Add(self.trackerList, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     vSizer.Add(StaticText(self, -1, 'Comment'))
     self.commentList = wx.TextCtrl(self, -1, '', style = wx.TE_MULTILINE)
     vSizer.Add(self.commentList, 0, wx.EXPAND|wx.BOTTOM, 3)
     
     abbrev_mb = " " + self.guiutility.utility.lang.get('MB')
     abbrev_kb = " " + self.guiutility.utility.lang.get('KB')
     piece_choices = [self.guiutility.utility.lang.get('automatic'), 
                      '2' + abbrev_mb, 
                      '1' + abbrev_mb, 
                      '512' + abbrev_kb, 
                      '256' + abbrev_kb, 
                      '128' + abbrev_kb, 
                      '64' + abbrev_kb, 
                      '32' + abbrev_kb]
     self.pieceChoice = wx.Choice(self, -1, choices = piece_choices)
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     hSizer.Add(StaticText(self, -1, 'Piecesize'), 1)
     hSizer.Add(self.pieceChoice)
     vSizer.Add(hSizer, 0, wx.EXPAND|wx.BOTTOM, 10)
     
     cancel = wx.Button(self, wx.ID_CANCEL)
     cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
     
     create = wx.Button(self, wx.ID_OK, 'Create .torrent(s)')
     create.Bind(wx.EVT_BUTTON, self.OnOk)
     
     bSizer = wx.StdDialogButtonSizer()
     bSizer.AddButton(cancel)
     bSizer.AddButton(create)
     bSizer.Realize()
     vSizer.Add(bSizer, 0, wx.EXPAND)
     
     sizer = wx.BoxSizer()
     sizer.Add(vSizer, 1, wx.EXPAND|wx.ALL, 10)
     self.SetSizerAndFit(sizer)
     
     self.selectedPaths = []
     self.createdTorrents = []
     self.cancelEvent = Event()
コード例 #10
0
 def __init__(self, parent_list, columns, leftSpacer = 0, rightSpacer = 0, singleExpanded = False, showChange = False, list_item_max = None, hasFilter = True, listRateLimit = LIST_RATE_LIMIT):
     self.columns = columns
     self.leftSpacer = leftSpacer
     self.rightSpacer = rightSpacer
     self.parent_list = parent_list
     self.singleExpanded = singleExpanded
     self.showChange = showChange
     self.list_selected = LIST_SELECTED
     self.listRateLimit = listRateLimit
     if not list_item_max:
         list_item_max = LIST_ITEM_MAX_SIZE
     self.list_item_max = list_item_max
     self.list_cur_max = self.list_item_max
     
     self.hasFilter = hasFilter
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     
     self.listpanel = wx.Panel(self, name="LIST")
     
     #vertical sizer containing all items
     self.vSizer = wx.BoxSizer(wx.VERTICAL)
     self.listpanel.SetSizer(self.vSizer)
     hSizer.Add(self.listpanel, 1)
     self.SetSizer(hSizer)
 
     #messagePanel text
     self.messagePanel = wx.Panel(self.listpanel)
     self.messagePanel.SetBackgroundColour(DEFAULT_BACKGROUND)
     self.messagePanel.Show(False)
     messageVSizer = wx.BoxSizer(wx.VERTICAL)
     
     self.headerText = StaticText(self.messagePanel)
     _set_font(self.headerText, fontweight=wx.FONTWEIGHT_BOLD)
     self.messageText = StaticText(self.messagePanel)
     self.loadNext = wx.Button(self.messagePanel)
     self.loadNext.Bind(wx.EVT_BUTTON, self.OnLoadMore)
     self.loadNext.Hide()
     
     messageVSizer.Add(self.headerText, 0, wx.EXPAND)
     messageVSizer.Add(self.messageText, 0, wx.EXPAND)
     messageVSizer.Add(self.loadNext, 0, wx.ALIGN_CENTER)
     self.messageText.sizer = messageVSizer
     self.messageText.altControl = None
     
     messageSizer = wx.BoxSizer(wx.HORIZONTAL)
     messageSizer.AddStretchSpacer()
     messageSizer.Add(messageVSizer, 0, wx.TOP|wx.BOTTOM, 7)
     messageSizer.AddStretchSpacer()
     self.messagePanel.SetSizer(messageSizer)
     
     #vertical scrollrate
     self.rate = None
     
     #states
     self.cur_expanded = None
     
     #quick filter
     self.filter = None
     self.filterMessage = None
         
     #sorting
     self.sortcolumn = None
     
     #queue lists
     self.done = True
     self.lastData = 0
     self.dataTimer = None
     self.data = None
     self.raw_data = None
     self.items = {}
     
     # Allow list-items to store the most recent mouse left-down events:
     self.lastMouseLeftDownEvent = None
     self.curWidth = -1
     self.Bind(wx.EVT_SIZE, self.OnEventSize)
コード例 #11
0
ファイル: CreateTorrent.py プロジェクト: jettan/swiftarm
    def __init__(self, parent, configfile, fileconfigfile, suggestedTrackers, toChannel=False):
        wx.Dialog.__init__(self, parent, -1, "Create a .torrent", size=(600, 200))
        self.guiutility = GUIUtility.getInstance()
        self.toChannel = toChannel

        vSizer = wx.BoxSizer(wx.VERTICAL)

        header = wx.StaticText(self, -1, "Browse for a file or files")
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.locationText = StaticText(self, -1, "")
        vSizer.Add(self.locationText, 0, wx.EXPAND | wx.BOTTOM, 3)

        browseButton = wx.Button(self, -1, "Browse")
        browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)

        browseDirButton = wx.Button(self, -1, "Browse for a Directory")
        browseDirButton.Bind(wx.EVT_BUTTON, self.OnBrowseDir)

        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(browseButton)
        hSizer.Add(browseDirButton)
        vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 3)

        # self.recursive = wx.CheckBox(self, -1, 'Include all subdirectories')
        # self.recursive.Bind(wx.EVT_CHECKBOX, self.OnRecursive)
        # vSizer.Add(self.recursive, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)

        vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        header = wx.StaticText(self, -1, ".Torrent details")
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.foundFilesText = StaticText(self, -1, "Please select a file or files first")
        vSizer.Add(self.foundFilesText, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.combineRadio = wx.RadioButton(self, -1, "Combine files into a single .torrent", style=wx.RB_GROUP)
        self.combineRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine)
        self.combineRadio.Enable(False)

        self.sepRadio = wx.RadioButton(self, -1, "Create separate .torrent for every file")
        self.sepRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine)
        self.sepRadio.Enable(False)

        vSizer.Add(self.combineRadio, 0, wx.EXPAND | wx.BOTTOM, 3)
        vSizer.Add(self.sepRadio, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.specifiedName = wx.TextCtrl(self, -1, "")
        self.specifiedName.Enable(False)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(wx.StaticText(self, -1, "Specify a name"), 0, wx.ALIGN_CENTER_VERTICAL)
        hSizer.Add(self.specifiedName, 1, wx.EXPAND)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, "Trackers"))
        self.trackerList = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
        self.trackerList.SetMinSize((500, -1))

        self.trackerHistory = wx.FileHistory(10)
        self.config = wx.FileConfig(appName="Tribler", localFilename=configfile)
        self.trackerHistory.Load(self.config)

        if self.trackerHistory.GetCount() > 0:
            trackers = [self.trackerHistory.GetHistoryFile(i) for i in range(self.trackerHistory.GetCount())]
            if len(trackers) < len(suggestedTrackers):
                trackers.extend(suggestedTrackers[: len(suggestedTrackers) - len(trackers)])
        else:
            trackers = suggestedTrackers

        for tracker in trackers:
            self.trackerList.AppendText(tracker + "\n")

        vSizer.Add(self.trackerList, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, "Comment"))
        self.commentList = wx.TextCtrl(self, -1, "", style=wx.TE_MULTILINE)
        vSizer.Add(self.commentList, 0, wx.EXPAND, 3)

        vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10)

        header = wx.StaticText(self, -1, "Advanced options")
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 3)

        abbrev_mb = " " + self.guiutility.utility.lang.get("MB")
        abbrev_kb = " " + self.guiutility.utility.lang.get("KB")
        piece_choices = [
            self.guiutility.utility.lang.get("automatic"),
            "4" + abbrev_mb,
            "2" + abbrev_mb,
            "1" + abbrev_mb,
            "512" + abbrev_kb,
            "256" + abbrev_kb,
            "128" + abbrev_kb,
            "64" + abbrev_kb,
            "32" + abbrev_kb,
        ]
        self.pieceChoice = wx.Choice(self, -1, choices=piece_choices)
        self.pieceChoice.SetSelection(0)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(StaticText(self, -1, "Piecesize"), 1)
        hSizer.Add(self.pieceChoice)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, "Webseed"))
        self.webSeed = wx.TextCtrl(self, -1, "Please select a file or files first")
        self.webSeed.Enable(False)
        vSizer.Add(self.webSeed, 0, wx.EXPAND | wx.BOTTOM, 3)

        cancel = wx.Button(self, wx.ID_CANCEL)
        cancel.Bind(wx.EVT_BUTTON, self.OnCancel)

        create = wx.Button(self, wx.ID_OK, "Create .torrent(s)")
        create.Bind(wx.EVT_BUTTON, self.OnOk)

        bSizer = wx.StdDialogButtonSizer()
        bSizer.AddButton(cancel)
        bSizer.AddButton(create)
        bSizer.Realize()
        vSizer.Add(bSizer, 0, wx.EXPAND)

        sizer = wx.BoxSizer()
        sizer.Add(vSizer, 1, wx.EXPAND | wx.ALL, 10)
        self.SetSizerAndFit(sizer)

        self.selectedPaths = []
        self.createdTorrents = []
        self.cancelEvent = Event()

        self.filehistory = wx.FileHistory(1)
        self.fileconfig = wx.FileConfig(appName="Tribler", localFilename=fileconfigfile)
        self.filehistory.Load(self.fileconfig)

        if self.filehistory.GetCount() > 0:
            self.latestFile = self.filehistory.GetHistoryFile(0)
        else:
            self.latestFile = ""
        self.paths = None
コード例 #12
0
    def AddComponents(self, leftSpacer, rightSpacer):
        if leftSpacer > 0:
            self.hSizer.AddSpacer((leftSpacer, -1))

        for i in xrange(len(self.columns)):
            if self.columns[i]['width'] == wx.LIST_AUTOSIZE:
                option = 1
                size = wx.DefaultSize
            else:
                option = 0
                size = (self.columns[i]['width'], -1)

            type = self.columns[i].get('type', 'label')
            if type == 'label':
                str_data = self.columns[i].get('fmt', unicode)(self.data[i])
                control = StaticText(self,
                                     style=self.columns[i].get('style', 0)
                                     | wx.ST_NO_AUTORESIZE | wx.ST_DOTS_END,
                                     size=size)

                fontWeight = self.columns[i].get('fontWeight',
                                                 wx.FONTWEIGHT_NORMAL)
                if fontWeight != wx.FONTWEIGHT_NORMAL:
                    _set_font(control, fontweight=fontWeight)

                #niels: wx magic prevents us from passing this string with the constructor, ampersands will not work
                control.SetLabel(str_data.replace('&', "&&"))

            elif type == 'method':
                control = self.columns[i]['method'](self, self)

            if control:
                control.icon = self._get_icon(i, 'icon')
                control.icon_right = self._get_icon(i, 'icon_right')
                self.controls.append(control)

                if i != 0:
                    self.hSizer.AddSpacer((3, -1))

                if control.icon:
                    self.hSizer.Add(control.icon, 0,
                                    wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)

                self.hSizer.Add(
                    control, option, wx.RESERVE_SPACE_EVEN_IF_HIDDEN
                    | wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 3)

                if control.icon_right:
                    self.hSizer.Add(control.icon_right, 0,
                                    wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 3)

                if self.columns[i]['width'] == wx.LIST_AUTOSIZE:
                    control.SetMinSize((1, -1))

                elif self.columns[i]['width'] == LIST_AUTOSIZEHEADER:
                    self.columns[i]['width'] = control.GetSize()[0]
                    if self.parent_list.parent_list.header:
                        self.parent_list.parent_list.header.ResizeColumn(
                            i, self.columns[i]['width'])
            else:
                if self.columns[i]['width'] != LIST_AUTOSIZEHEADER:
                    self.hSizer.Add((self.columns[i]['width'], -1), 0, wx.LEFT,
                                    3)

        if rightSpacer > 0:
            self.hSizer.AddSpacer((rightSpacer, -1))
        self.hSizer.Layout()

        self.AddEvents(self)
コード例 #13
0
    def __init__(self,
                 parent_list,
                 columns,
                 leftSpacer=0,
                 rightSpacer=0,
                 singleExpanded=False,
                 showChange=False,
                 list_item_max=None,
                 hasFilter=True,
                 listRateLimit=LIST_RATE_LIMIT):
        self.columns = columns
        self.leftSpacer = leftSpacer
        self.rightSpacer = rightSpacer
        self.parent_list = parent_list
        self.singleExpanded = singleExpanded
        self.showChange = showChange
        self.list_selected = LIST_SELECTED
        self.listRateLimit = listRateLimit
        if not list_item_max:
            list_item_max = LIST_ITEM_MAX_SIZE
        self.list_item_max = list_item_max
        self.list_cur_max = self.list_item_max

        self.hasFilter = hasFilter

        hSizer = wx.BoxSizer(wx.HORIZONTAL)

        self.listpanel = wx.Panel(self, name="LIST")

        #vertical sizer containing all items
        self.vSizer = wx.BoxSizer(wx.VERTICAL)
        self.listpanel.SetSizer(self.vSizer)
        hSizer.Add(self.listpanel, 1)
        self.SetSizer(hSizer)

        #messagePanel text
        self.messagePanel = wx.Panel(self.listpanel)
        self.messagePanel.SetBackgroundColour(DEFAULT_BACKGROUND)
        self.messagePanel.Show(False)
        messageVSizer = wx.BoxSizer(wx.VERTICAL)

        self.headerText = StaticText(self.messagePanel)
        _set_font(self.headerText, fontweight=wx.FONTWEIGHT_BOLD)
        self.messageText = StaticText(self.messagePanel)
        self.loadNext = wx.Button(self.messagePanel)
        self.loadNext.Bind(wx.EVT_BUTTON, self.OnLoadMore)
        self.loadNext.Hide()

        messageVSizer.Add(self.headerText, 0, wx.EXPAND)
        messageVSizer.Add(self.messageText, 0, wx.EXPAND)
        messageVSizer.Add(self.loadNext, 0, wx.ALIGN_CENTER)
        self.messageText.sizer = messageVSizer
        self.messageText.altControl = None

        messageSizer = wx.BoxSizer(wx.HORIZONTAL)
        messageSizer.AddStretchSpacer()
        messageSizer.Add(messageVSizer, 0, wx.TOP | wx.BOTTOM, 7)
        messageSizer.AddStretchSpacer()
        self.messagePanel.SetSizer(messageSizer)

        #vertical scrollrate
        self.rate = None

        #states
        self.cur_expanded = None

        #quick filter
        self.filter = None
        self.filterMessage = None

        #sorting
        self.sortcolumn = None

        #queue lists
        self.done = True
        self.lastData = 0
        self.dataTimer = None
        self.data = None
        self.raw_data = None
        self.items = {}

        # Allow list-items to store the most recent mouse left-down events:
        self.lastMouseLeftDownEvent = None
        self.curWidth = -1
        self.Bind(wx.EVT_SIZE, self.OnEventSize)
コード例 #14
0
ファイル: AddTorrent.py プロジェクト: ebcabaybay/swiftarm
 def __init__(self, parent, frame, libraryTorrents = None):
     wx.Dialog.__init__(self, parent, -1, 'Add an external .torrent', size=(500,200))
     
     self.frame = frame
     self.guiutility = GUIUtility.getInstance()
     self.toChannel = libraryTorrents != None
     self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance()
     
     vSizer = wx.BoxSizer(wx.VERTICAL)
     
     firstLine = wx.StaticText(self, -1, 'Please use one of the provided methods to import an external .torrent')
     vSizer.Add(firstLine, 0, wx.EXPAND|wx.BOTTOM, 3)
     vSizer.AddSpacer((-1, 25))
     
     header = wx.StaticText(self, -1, 'Browse for local .torrent file or files')
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM, 3)
     vSizer.Add(wx.StaticText(self, -1, 'Use this option if you have downloaded a .torrent manually'), 0, wx.BOTTOM, 3)
     
     browseButton = wx.Button(self, -1, 'Browse')
     browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)
     
     browseDirectory = wx.Button(self, -1, 'Browse for Directory')
     browseDirectory.Bind(wx.EVT_BUTTON, self.OnBrowseDir)
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     hSizer.Add(browseButton, 0, wx.RIGHT, 3)
     hSizer.Add(browseDirectory)
     vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)
     vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 10)
     
     header = wx.StaticText(self, -1, 'Url')
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)
     vSizer.Add(wx.StaticText(self, -1, 'This could either be a direct http-link (starting with http://), or a magnet link'), 0, wx.BOTTOM, 3)
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     self.magnet = wx.TextCtrl(self, -1)
     hSizer.Add(self.magnet, 1, wx.ALIGN_CENTER_VERTICAL)
     linkButton = wx.Button(self, -1, "Add")
     linkButton.Bind(wx.EVT_BUTTON, self.OnAdd)
     hSizer.Add(linkButton, 0, wx.LEFT, 3)
     vSizer.Add(hSizer, 0 , wx.EXPAND|wx.BOTTOM, 3)
     
     vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 10)
     if libraryTorrents != None:
         if len(libraryTorrents) > 0:
             header = wx.StaticText(self, -1, 'Choose one from you library')
             _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
             vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)
             
             torrentNames = [torrent.name for torrent in libraryTorrents]
             
             hSizer = wx.BoxSizer(wx.HORIZONTAL)
             self.libraryChoice = wx.Choice(self, -1, choices=torrentNames)
             self.libraryChoice.torrents = libraryTorrents
             hSizer.Add(self.libraryChoice, 1, wx.ALIGN_CENTER_VERTICAL)
             
             linkButton = wx.Button(self, -1, "Add")
             linkButton.Bind(wx.EVT_BUTTON, self.OnLibrary)
             
             hSizer.Add(linkButton, 0, wx.LEFT, 3)
             vSizer.Add(hSizer, 0 , wx.EXPAND|wx.BOTTOM, 3)
         
         vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.BOTTOM, 10)
         header = wx.StaticText(self, -1, 'Create your own .torrents')
         _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
         vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)
         vSizer.Add(wx.StaticText(self, -1, 'Using your own local files'), 0, wx.BOTTOM, 3)
         
         create = wx.Button(self, -1, 'Create')
         create.Bind(wx.EVT_BUTTON, self.OnCreate)
         vSizer.Add(create, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)
         
         self.choose = None
         
     else:
         self.choose = wx.CheckBox(self, -1, "Let me choose a downloadlocation for these torrents")
         self.choose.SetValue(self.defaultDLConfig.get_show_saveas())
         vSizer.Add(self.choose, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 3)
     
     sizer = wx.BoxSizer()
     sizer.Add(vSizer, 1, wx.EXPAND|wx.ALL, 10)
     self.SetSizerAndFit(sizer)
コード例 #15
0
ファイル: MoveTorrents.py プロジェクト: ebcabaybay/swiftarm
    def __init__(self, parent, labels, downloads):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           'Please select the torrents you want to move',
                           size=(750, 450))

        self.downloads = downloads
        vSizer = wx.BoxSizer(wx.VERTICAL)
        message = 'Please select all torrents which should be moved'
        message += "\nUse ctrl+a to select all/deselect all."

        firstLine = wx.StaticText(self, -1, message)
        _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(firstLine, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.listCtrl = CheckSelectableListCtrl(self)
        self.listCtrl.InsertColumn(0, 'Torrent')
        self.listCtrl.InsertColumn(1, 'Current Location')

        self.listCtrl.setResizeColumn(0)

        for i, label in enumerate(labels):
            row = self.listCtrl.InsertStringItem(sys.maxint, label)

            download = downloads[i]
            self.listCtrl.SetStringItem(row, 1, download.get_dest_dir())

        self.listCtrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)
        vSizer.Add(self.listCtrl, 1, wx.EXPAND | wx.BOTTOM | wx.TOP, 3)

        self.destTextCtrl = wx.TextCtrl(self)
        self.browseButton = wx.Button(self, -1, 'Browse')
        self.browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)

        moveTo = wx.StaticText(self, -1, 'Move to:')
        _set_font(moveTo, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(moveTo)
        vSizer.Add(
            wx.StaticText(
                self, -1,
                'Please note that all multi-file torrents create a directory themselves.\nYour new destination should specify the base dir for all torrents.'
            ))

        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(self.destTextCtrl, 1, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT,
                   3)
        hSizer.Add(self.browseButton, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT,
                   3)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.moveFiles = wx.CheckBox(
            self, -1, 'Move files from current destination to new destination')
        self.ignoreFiles = wx.CheckBox(
            self, -1,
            'Do not overwrite files already existing at new destination')

        vSizer.Add(self.moveFiles)
        vSizer.Add(self.ignoreFiles)

        cancel = wx.Button(self, wx.ID_CANCEL)
        cancel.Bind(wx.EVT_BUTTON, self.OnCancel)

        ok = wx.Button(self, wx.ID_OK)
        ok.Bind(wx.EVT_BUTTON, self.OnOk)

        bSizer = wx.StdDialogButtonSizer()
        bSizer.AddButton(cancel)
        bSizer.AddButton(ok)
        bSizer.Realize()
        vSizer.Add(bSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        sizer = wx.BoxSizer()
        sizer.Add(vSizer, 1, wx.EXPAND | wx.ALL, 10)
        self.SetSizer(sizer)
コード例 #16
0
    def __init__(self, parent, labels, downloads):
        wx.Dialog.__init__(self, parent, -1, 'Please select the torrents you want to move', size=(750,450))
        
        self.downloads = downloads
        vSizer = wx.BoxSizer(wx.VERTICAL)
        message = 'Please select all torrents which should be moved'
        message += "\nUse ctrl+a to select all/deselect all."
        
        firstLine = wx.StaticText(self, -1, message)
        _set_font(firstLine, fontweight = wx.FONTWEIGHT_BOLD)
        vSizer.Add(firstLine, 0, wx.EXPAND|wx.BOTTOM, 3)
              
        self.listCtrl = CheckSelectableListCtrl(self)
        self.listCtrl.InsertColumn(0, 'Torrent')
        self.listCtrl.InsertColumn(1, 'Current Location')
        
        self.listCtrl.setResizeColumn(0)
        
        for i, label in enumerate(labels):
            row = self.listCtrl.InsertStringItem(sys.maxint, label)
            
            download = downloads[i]
            self.listCtrl.SetStringItem(row, 1, download.get_dest_dir())

        self.listCtrl.SetColumnWidth(1, wx.LIST_AUTOSIZE)
        vSizer.Add(self.listCtrl, 1, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)

        self.destTextCtrl = wx.TextCtrl(self)
        self.browseButton = wx.Button(self, -1, 'Browse')
        self.browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)
        
        moveTo = wx.StaticText(self, -1, 'Move to:')
        _set_font(moveTo, fontweight = wx.FONTWEIGHT_BOLD)
        vSizer.Add(moveTo)
        vSizer.Add(wx.StaticText(self, -1, 'Please note that all multi-file torrents create a directory themselves.\nYour new destination should specify the base dir for all torrents.'))
        
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(self.destTextCtrl, 1, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 3)
        hSizer.Add(self.browseButton, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 3)
        vSizer.Add(hSizer, 0, wx.EXPAND|wx.BOTTOM, 3)
        
        self.moveFiles = wx.CheckBox(self, -1, 'Move files from current destination to new destination')
        self.ignoreFiles = wx.CheckBox(self, -1, 'Do not overwrite files already existing at new destination')
        
        vSizer.Add(self.moveFiles)
        vSizer.Add(self.ignoreFiles)
        
        cancel = wx.Button(self, wx.ID_CANCEL)
        cancel.Bind(wx.EVT_BUTTON, self.OnCancel)
        
        ok = wx.Button(self, wx.ID_OK)
        ok.Bind(wx.EVT_BUTTON, self.OnOk)
        
        bSizer = wx.StdDialogButtonSizer()
        bSizer.AddButton(cancel)
        bSizer.AddButton(ok)
        bSizer.Realize()
        vSizer.Add(bSizer, 0, wx.EXPAND|wx.BOTTOM, 3)
        
        sizer = wx.BoxSizer()
        sizer.Add(vSizer, 1, wx.EXPAND|wx.ALL, 10)
        self.SetSizer(sizer)
コード例 #17
0
 def __init__(self, parent, frame, libraryTorrents = None):
     wx.Dialog.__init__(self, parent, -1, 'Add an external .torrent', size=(500,200))
     
     self.frame = frame
     self.guiutility = GUIUtility.getInstance()
     self.toChannel = libraryTorrents != None
     self.defaultDLConfig = DefaultDownloadStartupConfig.getInstance()
     
     vSizer = wx.BoxSizer(wx.VERTICAL)
     
     firstLine = wx.StaticText(self, -1, 'Please use one of the provided methods to import an external .torrent')
     vSizer.Add(firstLine, 0, wx.EXPAND|wx.BOTTOM, 3)
     vSizer.AddSpacer((-1, 25))
     
     header = wx.StaticText(self, -1, 'Browse for local .torrent file or files')
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM, 3)
     vSizer.Add(wx.StaticText(self, -1, 'Use this option if you have downloaded a .torrent manually'), 0, wx.BOTTOM, 3)
     
     browseButton = wx.Button(self, -1, 'Browse')
     browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)
     
     browseDirectory = wx.Button(self, -1, 'Browse for Directory')
     browseDirectory.Bind(wx.EVT_BUTTON, self.OnBrowseDir)
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     hSizer.Add(browseButton, 0, wx.RIGHT, 3)
     hSizer.Add(browseDirectory)
     vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)
     vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
     
     header = wx.StaticText(self, -1, 'Url')
     _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
     vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)
     vSizer.Add(wx.StaticText(self, -1, 'This could either be a direct http-link (starting with http://), or a magnet link'), 0, wx.BOTTOM, 3)
     
     hSizer = wx.BoxSizer(wx.HORIZONTAL)
     self.magnet = wx.TextCtrl(self, -1)
     hSizer.Add(self.magnet, 1, wx.ALIGN_CENTER_VERTICAL)
     linkButton = wx.Button(self, -1, "Add")
     linkButton.Bind(wx.EVT_BUTTON, self.OnAdd)
     hSizer.Add(linkButton, 0, wx.LEFT, 3)
     vSizer.Add(hSizer, 0 , wx.EXPAND|wx.BOTTOM, 3)
     
     vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
     if libraryTorrents != None:
         if len(libraryTorrents) > 0:
             header = wx.StaticText(self, -1, 'Choose one from you library')
             _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
             vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)
             
             torrentNames = [torrent.name for torrent in libraryTorrents]
             
             hSizer = wx.BoxSizer(wx.HORIZONTAL)
             self.libraryChoice = wx.Choice(self, -1, choices=torrentNames)
             self.libraryChoice.torrents = libraryTorrents
             hSizer.Add(self.libraryChoice, 1, wx.ALIGN_CENTER_VERTICAL)
             
             linkButton = wx.Button(self, -1, "Add")
             linkButton.Bind(wx.EVT_BUTTON, self.OnLibrary)
             
             hSizer.Add(linkButton, 0, wx.LEFT, 3)
             vSizer.Add(hSizer, 0 , wx.EXPAND|wx.BOTTOM, 3)
         
         vSizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.BOTTOM, 10)
         header = wx.StaticText(self, -1, 'Create your own .torrents')
         _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
         vSizer.Add(header, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 3)
         vSizer.Add(wx.StaticText(self, -1, 'Using your own local files'), 0, wx.BOTTOM, 3)
         
         create = wx.Button(self, -1, 'Create')
         create.Bind(wx.EVT_BUTTON, self.OnCreate)
         vSizer.Add(create, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)
         
         self.choose = None
         
     else:
         self.choose = wx.CheckBox(self, -1, "Let me choose a downloadlocation for these torrents")
         self.choose.SetValue(self.defaultDLConfig.get_show_saveas())
         vSizer.Add(self.choose, 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 3)
     
     sizer = wx.BoxSizer()
     sizer.Add(vSizer, 1, wx.EXPAND|wx.ALL, 10)
     self.SetSizerAndFit(sizer)
コード例 #18
0
ファイル: RemoveTorrent.py プロジェクト: ebcabaybay/swiftarm
    def __init__(self, parent, torrent):
        canEdit = canComment = False
        if torrent.hasChannel():
            state, iamModerator = torrent.channel.getState()
            canEdit = state >= ChannelCommunity.CHANNEL_OPEN

        height = 125
        if canEdit:
            height = 200

        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           'Are you sure you want to remove this torrent?',
                           size=(600, height))
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(
            wx.StaticBitmap(
                self, -1,
                wx.ArtProvider.GetBitmap(wx.ART_QUESTION, wx.ART_MESSAGE_BOX)),
            0, wx.RIGHT, 10)

        vSizer = wx.BoxSizer(wx.VERTICAL)
        firstLine = StaticText(
            self, -1,
            "Delete '%s' from disk, or just remove them from your downloads?" %
            torrent.name)
        _set_font(firstLine, fontweight=wx.FONTWEIGHT_BOLD)
        firstLine.SetMinSize((1, -1))

        vSizer.Add(firstLine, 0, wx.EXPAND | wx.BOTTOM, 3)
        vSizer.Add(
            StaticText(
                self, -1,
                "Removing from disk will move the selected item to your trash."
            ), 0, wx.EXPAND)

        vSizer.AddStretchSpacer()

        self.newName = None
        if canEdit:
            vSizer.Add(
                StaticText(
                    self, -1,
                    "While we're at it, can you improve the name of this torrent?"
                ), 0, wx.EXPAND | wx.BOTTOM, 3)
            self.newName = EditText(self, torrent.name)
            vSizer.Add(self.newName, 0, wx.EXPAND)
            vSizer.AddStretchSpacer()

        bSizer = wx.BoxSizer(wx.HORIZONTAL)
        bSizer.AddStretchSpacer()

        bSizer.Add(wx.Button(self, wx.ID_CANCEL), 0, wx.RIGHT, 3)
        bSizer.Add(
            wx.Button(self, wx.ID_DEFAULT, 'Only delete from downloads'), 0,
            wx.RIGHT, 3)
        bSizer.Add(wx.Button(self, wx.ID_DELETE, 'Also delete from disk'))

        vSizer.Add(bSizer, 0, wx.ALIGN_RIGHT | wx.TOP, 7)
        hSizer.Add(vSizer, 1, wx.EXPAND)

        border = wx.BoxSizer()
        border.Add(hSizer, 1, wx.ALL | wx.EXPAND, 10)

        self.Bind(wx.EVT_BUTTON, lambda event: self.EndModal(event.GetId()))
        self.SetSizer(border)
        self.Layout()
        self.CenterOnParent()