我有一個主窗口,當用戶選擇要上傳的文件,然後一個新的窗口將打開文件,即文件名,上傳速度,時間的顯示狀態左等(如IDM和xdman)進度條將無法正常工作,如果添加多個窗口(pyside)
當用戶添加一個文件上傳的一切過程以及
問題就來了,如果用戶想要添加更多的文件上傳
一個窗口將停止更新數據(這應該持續到上傳完成)
秒窗口顯示繼續更新信息,但進度條將獲得與第一窗口(我的意思是這兩個進度條將在第二個窗口顯示在同一時間混! ) 我應該如何讓他們分開? 這裏是短版的我的代碼明白我做了什麼!
class Window(QtGui.QWidget):
def __init__(self, parent=None):
super(Window, self).__init__(parent)
self.table = QtGui.QTableWidget(self)#progressbar work perfectly in table but not in new windows !
def handleAddUpload(self):
#choosing a file codes go here
progress = QtGui.QProgressBar(self.table)
progress.setRange(0, len(data))
#two above line will add progressbar to table !
tabs = self.createTab() #caling createTab for creating new window for...
def handleUploadProgress(self, key, sent, total):
#handleeUploadProgress method call rapidly since data needs to be stream and update !
progress = self.table.cellWidget(key, 0)
progress.setValue(sent)
#two above line will update value in table without any problem
self.procbar.setValue(sent) #this line call progressbar value from createTab()
def createTab(self): #all my problems are in this method
self.tab = QtGui.QTabWidget()
layout = QtGui.QVBoxLayout(self)
tab = QtGui.QWidget()
layout1 = QtGui.QVBoxLayout(tab)
self.procbar = QtGui.QProgressBar()
self.procbar.setStyleSheet("")
self.procbar.setRange(0, 0) #a range added in handleaddupload,for shorting this I didn't show that
self.procbar.setValue(0)
layout1.addWidget(self.procbar)
self.tab.addTab(tab, 'Upload Status')
layout.addWidget(self.tab)
self.tab.show()
def handleUploadFinished(self, key):
#codes.....
我認爲這是進度
由於我是新來的Python/pyside我要求幫助和here is the base of my code(我開始與這個答案)
這裏它有關的一切是我的短問題:如何添加單獨的獨特小部件以同時顯示多個進度欄?
謝謝你們閱讀這個無聊的問題
更新1: 這裏是軟件
圖片當我添加Pharrell的歌曲上傳表和單獨的窗口同時顯示進度條以及,但是當我添加新的歌曲上傳(賈斯汀):
1在單獨的窗口中的進度條Pharrell的停止工作(如你所看到的比例是不一樣的)!
2,進度條(只在單獨的窗口中)新增加的歌曲節目都進步%的(它很快變爲10%和26%)
(在表中的所有情況進度條工作)
你的問題不是無聊,但有點不清楚。你爲什麼需要兩個窗戶?爲什麼不把所有上傳添加到一個表?如果你解釋你的程序的總體設計是什麼,這將有所幫助。 – ekhumoro
嗨ekhumoro,謝謝你再次幫助我。你是完美的。我只是更新了我的問題,以清除我的問題:) – Mohammadhzp