我在将值更新到进度条时遇到问题,当我运行程序时,进度条卡在中间(只需单击下面的“在这里出现问题”按钮,它说明了我的意思),代码成功运行,而没有任何错误
这是我使用的代码:
self.bytes = 0
self.max_bytes = 0
self.progressbarframe = Frame(self.frameoutput, bg=self.bgcolor)
self.progressbarframe.place(relx=0.355,rely=0.78,relwidth=0.605)
self.progressbar = Progressbar(self.progressbarframe, orient=HORIZONTAL, mode='determinate')
self.progressbar.pack(fill=X)
def progress(curvalue, maxval):
self.progressbar['value'] = curvalue
self.progressbar['maximum'] = maxval
def cb(total, recvd, ratio, rate, eta):
self.bytes += recvd
self.max_bytes += total
if self.bytes <= self.max_bytes:
self.progressbar.after(50, progress(self.bytes, self.max_bytes))
self.progressbar.update()
self.videos = pafy.new(str(self.entryyturl.get()))
self.videodownload = self.videos.allstreams
self.videodownload = self.videodownload[-int(self.data['mediatypes'].index(self.resolutionbox.get()))-1]
self.videodownload.download(quiet=True, filepath='download/{}.{}'.format(self.videodownload.title, self.videodownload.extension), callback=cb)
谢谢!