def __init__ (self, title, mmax=100) :
super (FamilyProgress, self).__init__ ()
self.setWindowTitle (title)
self.setFixedHeight (48)
self.pbar = QtGui.QProgressBar ()
self.pbar.setRange (0, mmax - 1)
self.btn = QtGui.QPushButton ("Starting", self)
pbarvbox = QtGui.QVBoxLayout()
pbarvbox.addStretch (False)
pbarvbox.addWidget (self.pbar)
buttonvbox = QtGui.QVBoxLayout ()
buttonvbox.addStretch (True)
buttonvbox.addWidget (self.btn)
hbox = QtGui.QHBoxLayout ()
hbox.addLayout(pbarvbox, stretch=False)
hbox.addLayout(buttonvbox)
self.setLayout (hbox)
self.pbar.setStyleSheet(START_STYLE)
#self.show()
python类QProgressBar()的实例源码
def setupUi(self):
"""Bruh"""
self.setGeometry(50, 50, 450, 250)
self.setWindowTitle("ZeZe's TWTools - Updating Servers")
self.setWindowIcon(QtGui.QIcon(resource_path("images/icon.png")))
"""Background color"""
self.backgroundPalette = QtGui.QPalette()
self.backgroundColor = QtGui.QColor(217, 204, 170)
self.backgroundPalette.setColor(QtGui.QPalette.Background, self.backgroundColor)
self.setPalette(self.backgroundPalette)
"""Layout"""
self.verticalLayout = QtGui.QVBoxLayout(self)
self.text = QtGui.QLabel("Updating server list:")
self.verticalLayout.addWidget(self.text)
"""Download bar"""
self.progress_bar = QtGui.QProgressBar(self)
self.progress_bar.setMinimum(0)
self.progress_bar.setMaximum(27)
self.progress_bar.setValue(0)
self.progress_bar.setFormat("%v / %m")
self.verticalLayout.addWidget(self.progress_bar)
"""Text browser for progress"""
self.progress_text = QtGui.QTextBrowser(self)
self.verticalLayout.addWidget(self.progress_text)
"""Button"""
self.horizontalLayout = QtGui.QHBoxLayout(self)
self.verticalLayout.addLayout(self.horizontalLayout)
self.Spacer = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
self.horizontalLayout.addItem(self.Spacer)
self.cancelButton = QtGui.QPushButton("Cancel")
self.horizontalLayout.addWidget(self.cancelButton)
self.cancelButton.clicked.connect(self.cancel_function)
def _add_pane_3(self):
"""
Add pane 3, an intermediate pane while we are sampling the posterior.
"""
self.p3 = QtGui.QWidget()
self.layout.addWidget(self.p3)
# Pane 3
p3_layout = QtGui.QGridLayout()
self.p3.setLayout(p3_layout)
p3_layout.addItem(QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding), 0, 1, 1, 1)
self.p3_progressbar = QtGui.QProgressBar(self)
self.p3_progressbar.setFocusPolicy(QtCore.Qt.NoFocus)
p3_layout.addWidget(self.p3_progressbar, 2, 1, 1, 1)
p3_layout.addItem(QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Minimum), 2, 2, 1, 1)
p3_layout.addItem(QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Minimum), 2, 0, 1, 1)
self.p3_label = QtGui.QLabel(self)
self.p3_label.setText("Sampling posterior")
self.p3_label.setAlignment(QtCore.Qt.AlignCenter)
p3_layout.addWidget(self.p3_label, 1, 1, 1, 1)
p3_layout.addItem(QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum,
QtGui.QSizePolicy.Expanding), 3, 1, 1, 1)
return None
def initUI(self):
self._layout = QtGui.QGridLayout(None)
self.setLayout(self._layout)
self._layout.setContentsMargins(0,5,0,5)
self._layout.setSpacing(0)
self._topBar = QtGui.QFrame()
self._topBarLayout = QtGui.QHBoxLayout(self._topBar)
self._refreshProgression = QtGui.QProgressBar()
self._refreshProgression.setMinimum(0)
self._refreshProgression.setMaximum(100)
self._refreshProgression.setValue(10)
self._refreshButton = QtGui.QPushButton("Refresh")
self._filterLabel = QtGui.QLabel("Filter :")
self._filterField = QtGui.QLineEdit()
self._topBarLayout.addWidget(self._refreshProgression)
self._topBarLayout.addWidget(self._refreshButton)
self._topBarLayout.addWidget(self._filterLabel)
self._topBarLayout.addWidget(self._filterField)
self.generateJobList()
self._layout.addWidget(self._topBar)
self._layout.addWidget(self._jobList)
self._autoRefresh = JobListAutoRefresh(self,self._refreshProgression)
#autoRefresh.run()
self._refreshButton.clicked.connect(self.startRefresh)
def dialog():
w=QtGui.QWidget()
box = QtGui.QVBoxLayout()
w.setLayout(box)
w.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
l=QtGui.QLabel("String" )
box.addWidget(l)
w.anz = QtGui.QLineEdit()
w.anz.setText('OK')
box.addWidget(w.anz)
l=QtGui.QLabel("Degree" )
box.addWidget(l)
w.degree = QtGui.QLineEdit()
w.degree.setText('0')
box.addWidget(w.degree)
w.r=QtGui.QPushButton("run")
box.addWidget(w.r)
w.r.pressed.connect(lambda :_run(w))
w.progressbar=QtGui.QProgressBar()
box.addWidget(w.progressbar)
w.show()
return w
def create_download_bar(self):
hlayout = QtGui.QHBoxLayout()
vlayout = QtGui.QVBoxLayout()
vlayout.setContentsMargins(5, 5, 5, 5)
vlayout.setSpacing(5)
hlayout.setSpacing(5)
hlayout.setContentsMargins(5, 5, 5, 5)
progress_label = QtGui.QLabel('')
progress_bar = QtGui.QProgressBar()
progress_bar.setVisible(False)
progress_bar.setContentsMargins(5, 5, 5, 5)
vlayout.addWidget(progress_label)
vlayout.addWidget(progress_bar)
vlayout.addWidget(QtGui.QLabel(''))
ex_button = QtGui.QPushButton('Export')
ex_button.setEnabled(False)
cancel_button = QtGui.QPushButton('Cancel Download')
cancel_button.setEnabled(False)
open_export_button = QtGui.QPushButton()
open_export_button.setEnabled(False)
open_export_button.setIcon(QtGui.QIcon(get_file('files/images/folder_open.png')))
open_export_button.setToolTip('Open Export Folder')
open_export_button.setStatusTip('Open Export Folder')
open_export_button.setMaximumWidth(30)
open_export_button.setMaximumHeight(30)
ex_button.clicked.connect(self.call_with_object('export', ex_button, cancel_button))
cancel_button.clicked.connect(self.cancel_download)
open_export_button.clicked.connect(self.call_with_object('open_export', open_export_button))
button_box = QtGui.QDialogButtonBox()
button_box.addButton(open_export_button, QtGui.QDialogButtonBox.NoRole)
button_box.addButton(cancel_button, QtGui.QDialogButtonBox.RejectRole)
button_box.addButton(ex_button, QtGui.QDialogButtonBox.AcceptRole)
hlayout.addLayout(vlayout)
hlayout.addWidget(button_box)
self.progress_label = progress_label
self.progress_bar = progress_bar
self.cancel_button = cancel_button
self.open_export_button = open_export_button
http = QHttp(self)
http.sslErrors.connect(self.https_error)
http.requestFinished.connect(self.http_request_finished)
http.dataReadProgress.connect(self.update_progress_bar)
http.responseHeaderReceived.connect(self.read_response_header)
self.http = http
self.ex_button = ex_button
return hlayout
def __init__(self):
super(LocoWidget,self).__init__()
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
self.setWindowTitle('Locometry v2.1')
self.header = QtGui.QPixmap(os.path.split(__file__)[0]+'/icons/logo.png')
self.headerLBL = QtGui.QLabel()
self.headerLBL.setPixmap(self.header)
self.vLayout = QtGui.QVBoxLayout()
self.vLayout.addWidget(self.headerLBL)
self.typeCombo = QtGui.QComboBox()
self.typeCombo.addItems(['Axis','Card','Sphere','Cube','Cylinder','Selected Node'])
self.frangeLBL = QtGui.QLabel('Frame Range')
self.firstLE = QtGui.QLineEdit()
self.lastLE = QtGui.QLineEdit()
self.trackBTN = QtGui.QPushButton('snap')
self.locoDic = {}
self.progressBar = QtGui.QProgressBar()
self.progressBar.setMinimum(1)
self.progressBar.setMaximum(100)
self.progressBar.setFormat('Snapping '+self.typeCombo.currentText())
self.progressBar.setObjectName("progressBar")
self.layout = QtGui.QHBoxLayout()
self.layout.addWidget(self.typeCombo)
self.layout.addWidget(self.frangeLBL)
self.layout.addWidget(self.firstLE)
self.layout.addWidget(self.lastLE)
self.layout.addWidget(self.trackBTN)
self.vLayout.addLayout(self.layout)
self.vLayout.addWidget(self.progressBar)
self.progressBar.hide()
self.setLayout(self.vLayout)
self.locoThread = None
self.trackBTN.clicked.connect(self.trackSelectedVertices)
def init_left_pane(self):
self.left_pane = QtGui.QVBoxLayout()
# NICHE COMBO: make dropdown menu to select a fetish
self.niche_combo = QtGui.QComboBox(self)
keys = sorted(self.xpaths.keys())
for k in keys:
self.niche_combo.addItem(k)
self.niche_combo.setCurrentIndex(0)
self.niche = keys[0]
self.niche_combo.activated[str].connect(self.set_niche)
self.left_pane.addWidget(self.niche_combo)
# START PG AND PGS TO SCRAPE
self.left_pane.addSpacing(50)
self.init_page_btns()
self.left_pane.addSpacing(25)
# PROGRESS BAR: tracks the progress of the scraper
self.prog = QtGui.QProgressBar(self)
self.left_pane.addWidget(self.prog)
# SCRAPE: begin scraping
self.scrape_btn = QtGui.QPushButton("scrape", self)
self.scrape_btn.clicked.connect(self.scrape)
self.left_pane.addWidget(self.scrape_btn)
self.left_pane.addSpacing(25)
# LOAD URL: load a specific url, presumably for rating.
self.load_url_box = QtGui.QLineEdit()
self.load_url_box.setPlaceholderText("load a specific url")
self.feedback_spin = QtGui.QSpinBox()
self.feedback_spin.setMaximum(100) # (ratings must be between 0 and 100)
self.enter_btn = QtGui.QPushButton("save") # also on bottom is the enter/save button
self.enter_btn.clicked.connect(lambda: self.save_usr_url())
self.load_url_extra = QtGui.QHBoxLayout() # put feedback and enter in one row
self.load_url_extra.addWidget(self.feedback_spin)
self.load_url_extra.addWidget(self.enter_btn)
self.load_url_group = QtGui.QVBoxLayout() # group it all together
self.load_url_group.addWidget(self.load_url_box)
self.load_url_group.addLayout(self.load_url_extra)
self.left_pane.addLayout(self.load_url_group)
self.left_pane.addSpacing(25)
# RETRAIN: manual retraining of prediction algorithm
self.train_btn = QtGui.QPushButton("recalculate prediction model", self)
self.train_btn.clicked.connect(self.retrain)
self.left_pane.addWidget(self.train_btn)
self.left_pane.addSpacing(50)
# QUIT: make quit button
self.quit_btn = QtGui.QPushButton("quit", self)
self.quit_btn.clicked.connect(self.quit)
self.left_pane.addWidget(self.quit_btn)
self.layout.addLayout(self.left_pane)
def findQubeItems(self,*args):
import datetime
self.qubeTable.setSortingEnabled(False)
omit=['killed','failed','blocked']
if self.qubeCompleteChbox.isChecked():
omit.append('complete')
#reset table
for r in range(self.qubeTable.rowCount()):
self.qubeTable.removeRow(0)
for k in self.qubeStatus.keys():
qubeJob=self.qubeStatus[k]
if self.seqSelection.currentText() in qubeJob['seq']:
if not qubeJob['status'] in omit:
if self.qubeGroupCombo.currentText() in qubeJob['groups']:
if not self.qubeShotChbox.checkState() or self.selShot in qubeJob['name']:
if datetime.datetime.fromtimestamp(qubeJob['timecomplete']) > self.qubeDateTimeEdit.dateTime().toPython() or qubeJob['timecomplete']==946702800:
self.qubeDateTimeEdit.dateTime().toPython()
rowNum=self.qubeTable.rowCount()
self.qubeTable.insertRow(rowNum)
self.qubeTable.setRowHeight(rowNum, 15)
#set itemName
item=QtGui.QTableWidgetItem()
item.setText(qubeJob['name'])
self.qubeTable.setItem(rowNum,0,item)
#set itemStatus
item=QtGui.QTableWidgetItem()
item.setText(qubeJob['status'])
self.qubeTable.setItem(rowNum,1,item)
#set percentage
item=QtGui.QTableWidgetItem()
progBar=QtGui.QProgressBar()
progBar.setMaximum(int(qubeJob['todo']))
progBar.setValue(int(qubeJob['todotally']['complete']))
#item.addWidget(progBar)
#item.setText(str(qubeJob['todo']))
self.qubeTable.setCellWidget(rowNum,2,progBar)
if qubeJob['status']=='complete':
#set complete time
item=QtGui.QTableWidgetItem()
date = datetime.datetime.fromtimestamp(qubeJob['timecomplete'])
item.setText(date.strftime("%m/%d %I:%M%p"))
self.qubeTable.setItem(rowNum,3,item)
self.qubeTable.setSortingEnabled(True)