def threadSetSings(self):
        if not self.result:
            return
        length = len(self.singPicUrls)

        for i in range(30):
            i += self.offset
            # 根本原因是不足30个。
            if i >= length:
                self.offsetComplement = length % 30
                break

            picName = makeMd5(self.singPicUrls[i])
            frame = OneSing(self.gridRow, self.gridColumn, self.playlistIds[i],
                            self, picName)
            frame.clicked.connect(self.startRequest)
            frame.nameLabel.setText(self.singNames[i])

            self.netEase.mainLayout.addWidget(frame, self.gridRow,
                                              self.gridColumn)
            # 建立起索引,一是防止垃圾回收了,二是可以找到他的地址。
            self.singsFrames.append(frame)

            # 用于布局,一行4个。
            if self.gridColumn == 3:
                self.gridColumn = 0
                self.gridRow += 1
            else:
                self.gridColumn += 1

            try:
                cacheList = os.listdir('cache')
            except:
                os.mkdir('cache')
                cacheList = os.listdir('cache')

            url = self.singPicUrls[i]

            # names = str(url[url.rfind('/')+1:])
            names = makeMd5(url)
            if names in cacheList:
                frame.setStyleSheets(
                    "QLabel#picLabel{border-image: url(cache/%s)}" % (names))
            else:
                task = _PicThreadTask(self.queue, frame, url)
                self.picThreadPool.start(task)
        else:
            # 如果顺利进行会将offsetComplement变成原30。
            self.offsetComplement = 30
Ejemplo n.º 2
0
    def threadSetSings(self):
        if not self.result:
            return 
        length = len(self.singPicUrls)

        for i in range(30):
            i += self.offset
            # 根本原因是不足30个。
            if i >= length:
                self.offsetComplement = length % 30 
                break

            picName = makeMd5(self.singPicUrls[i])
            frame = OneSing(self.gridRow, self.gridColumn, self.playlistIds[i], self, picName)
            frame.clicked.connect(self.startRequest)
            frame.nameLabel.setText(self.singNames[i])
            
            self.netEase.mainLayout.addWidget(frame, self.gridRow, self.gridColumn)
            # 建立起索引,一是防止垃圾回收了,二是可以找到他的地址。
            self.singsFrames.append(frame)

            # 用于布局,一行4个。
            if self.gridColumn == 3:
                self.gridColumn = 0
                self.gridRow += 1
            else:
                self.gridColumn += 1

            try:
                cacheList = os.listdir('cache')
            except:
                os.mkdir('cache')
                cacheList = os.listdir('cache')
            
            url = self.singPicUrls[i]

            # names = str(url[url.rfind('/')+1:])   
            names = makeMd5(url)
            if names in cacheList:
                frame.setStyleSheets("QLabel#picLabel{border-image: url(cache/%s)}"%(names))
            else:
                task = _PicThreadTask(self.queue, frame, url)
                self.picThreadPool.start(task)
        else:
            # 如果顺利进行会将offsetComplement变成原30。
            self.offsetComplement = 30
Ejemplo n.º 3
0
 def run(self):
     names = makeMd5(self.url)
     content = network.Requests.get(self.url).content
     pic = QPixmap()
     pic.loadFromData(content)
     # 缩小到合适的大小会让QT合理的利用内存资源。
     pic = pic.scaled(180, 180)
     a = pic.save("cache/{0}".format(names), 'jpg')
     self.queue.put([self.widget, "QLabel#picLabel{border-image: url(cache/%s)}"%(names)])
Ejemplo n.º 4
0
 def run(self):
     names = makeMd5(self.url)
     content = network.Requests.get(self.url).content
     pic = QPixmap()
     pic.loadFromData(content)
     # 缩小到合适的大小会让QT合理的利用内存资源。
     pic = pic.scaled(180, 180)
     a = pic.save("cache/{0}".format(names), 'jpg')
     self.queue.put([self.widget, "QLabel#picLabel{border-image: url(cache/%s)}"%(names)])