本文整理汇总了Python中PyQt5.QtWidgets.QProgressBar.setStyleSheet方法的典型用法代码示例。如果您正苦于以下问题:Python QProgressBar.setStyleSheet方法的具体用法?Python QProgressBar.setStyleSheet怎么用?Python QProgressBar.setStyleSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QProgressBar
的用法示例。
在下文中一共展示了QProgressBar.setStyleSheet方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Loading
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class Loading(QWidget):
ON = False #to prevent multiple instances
def __init__(self, parent=None):
super().__init__(parent)
self.widget = QWidget(self)
self.progress = QProgressBar()
self.progress.setStyleSheet("color:white")
self.text = QLabel()
self.text.setAlignment(Qt.AlignCenter)
self.text.setStyleSheet("color:white;background-color:transparent;")
layout_ = QHBoxLayout()
inner_layout_ = QVBoxLayout()
inner_layout_.addWidget(self.text, 0, Qt.AlignHCenter)
inner_layout_.addWidget(self.progress)
self.widget.setLayout(inner_layout_)
layout_.addWidget(self.widget)
self.setLayout(layout_)
self.resize(300,100)
#frect = self.frameGeometry()
#frect.moveCenter(QDesktopWidget().availableGeometry().center())
self.move(parent.window().frameGeometry().topLeft() +
parent.window().rect().center() -
self.rect().center() - QPoint(self.rect().width()//2,0))
#self.setAttribute(Qt.WA_DeleteOnClose)
#self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
def mousePressEvent(self, QMouseEvent):
pass
def setText(self, string):
if string != self.text.text():
self.text.setText(string)
示例2: Loading
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class Loading(QWidget):
ON = False #to prevent multiple instances
def __init__(self):
from ..constants import WINDOW as parent
super().__init__(parent, Qt.FramelessWindowHint)
self.widget = QWidget(self)
self.widget.setStyleSheet("background-color:rgba(0, 0, 0, 0.65)")
self.progress = QProgressBar()
self.progress.setStyleSheet("color:white")
self.text = QLabel()
self.text.setAlignment(Qt.AlignCenter)
self.text.setStyleSheet("color:white;background-color:transparent;")
layout_ = QHBoxLayout()
inner_layout_ = QVBoxLayout()
inner_layout_.addWidget(self.text, 0, Qt.AlignHCenter)
inner_layout_.addWidget(self.progress)
self.widget.setLayout(inner_layout_)
layout_.addWidget(self.widget)
self.setLayout(layout_)
self.resize(300,100)
self.move(parent.window().rect().center()-QPoint(120,50))
def mousePressEvent(self, QMouseEvent):
pass
def setText(self, string):
if string != self.text.text():
self.text.setText(string)
示例3: qualityWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class qualityWidget(QWidget):
def __init__(self,winParent, laser1, laser2, laser3):
super(qualityWidget, self).__init__()
self.winParent=winParent
self.laser1 = laser1
self.laser2 = laser2
self.laser3 = laser3
self.numCrash = 0
self.MAX_CRASH = 1000
vLayout = QVBoxLayout()
crashLabel = QLabel("Crash:")
self.bar = QProgressBar()
self.bar.setValue(self.numCrash)
st = "QProgressBar::chunk {background-color: #ff0000;}\n QProgressBar {border: 1px solid grey;border-radius: 2px;text-align: center;background: #eeeeee;}"
self.bar.setStyleSheet(st)
self.bar.setTextVisible(False)
vLayout.addWidget(crashLabel, 0)
vLayout.addWidget(self.bar, 0)
vSpacer = QSpacerItem(30, 80, QSizePolicy.Ignored, QSizePolicy.Ignored)
vLayout.addItem(vSpacer)
self.setLayout(vLayout)
def get_laser_distance(self, laser):
DIST = 15
maxAngle = 180
crash = False
for i in range(0, maxAngle+1):
# Distance in millimeters, we change to cm
laserI = float(laser.distanceData[i])/float(10)
if i != 0 and i != 180:
if laserI <= DIST:
crash = True
return crash
def updateG(self):
laser_data_Front = self.laser1.getLaserData()
laser_data_Rear = self.laser2.getLaserData()
laser_data_Right = self.laser3.getLaserData()
crashFront = self.get_laser_distance(laser_data_Front)
crashRear = self.get_laser_distance(laser_data_Rear)
crashRight = self.get_laser_distance(laser_data_Right)
if crashFront or crashRear or crashRight:
self.numCrash = self.numCrash + 1
percentajeCrash = self.numCrash * 100/self.MAX_CRASH
self.bar.setValue(self.numCrash)
self.update()
示例4: DownloadWidgetItem
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class DownloadWidgetItem(QTreeWidgetItem):
"""
This class is responsible for managing the item in the downloads list and fills the item with the relevant data.
"""
def __init__(self, parent):
super(DownloadWidgetItem, self).__init__(parent)
self.progress_slider = QProgressBar()
self.progress_slider.setStyleSheet("""
QProgressBar {
margin: 4px;
background-color: white;
color: #ddd;
font-size: 12px;
text-align: center;
}
QProgressBar::chunk {
background-color: #e67300;
}
""")
parent.setItemWidget(self, 2, self.progress_slider)
self.setSizeHint(0, QSize(-1, 24))
self.download_status_raw = -1
def updateWithDownload(self, download):
self.setText(0, download["name"])
self.setText(1, download["size"])
self.progress_slider.setValue(int(download["progress"] * 100))
self.setText(3, DLSTATUS_STRINGS[download["status"]])
self.setText(4, str(download["seeds"]))
self.setText(5, str(download["peers"]))
self.setText(6, str(download["down_speed"]))
self.setText(7, str(download["up_speed"]))
self.setText(8, "-")
self.download_status_raw = download["status"]
示例5: PowerIndicator
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class PowerIndicator():
parent = None
progressbar = None
text = None
maxVoltPerCell = 0
minVoltPerCell = 0
fullStyle = "QProgressBar::chunk { background-color: #00EE00; }"
halfStyle = "QProgressBar::chunk { background-color: #FFCC00; }"
emptyStyle = "QProgressBar::chunk { background-color: #FF5050; }"
def __init__(self, parent, minVoltPerCell = 3.2, maxVoltPerCell = 4.2):
self.minVoltPerCell = 3.2
self.maxVoltPerCell = 4.2
self.parent = parent
self.text = QLabel('', parent)
self.progressbar = QProgressBar(parent)
self.progressbar.setMaximumWidth(100)
self.progressbar.setMaximumHeight(10)
self.progressbar.setMaximum(100)
self.progressbar.setMinimum(0)
self.progressbar.setTextVisible(False)
parent.statusBar.addPermanentWidget(self.progressbar)
parent.statusBar.addPermanentWidget(self.text)
def updateProgressBar(self, voltage):
pct = ((voltage - self.minVoltPerCell) / (self.maxVoltPerCell-self.minVoltPerCell))*100
self.progressbar.setValue(pct)
if pct <= 20:
self.progressbar.setStyleSheet(self.emptyStyle)
elif pct <= 50:
self.progressbar.setStyleSheet(self.halfStyle)
else:
self.progressbar.setStyleSheet(self.fullStyle)
def newMessage(self, message, data):
if message == 'POW':
data = data.split()
if len(data) < 2:
return
volts = unpack('!f', bytes.fromhex(data[0]))[0]
amps = unpack('!f', bytes.fromhex(data[1]))[0]
self.text.setText("%.2f V/cell, %.3f A" % (volts/4, amps))
self.updateProgressBar(volts/4)
示例6: DownloadWidgetItem
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class DownloadWidgetItem(QTreeWidgetItem):
"""
This class is responsible for managing the item in the downloads list and fills the item with the relevant data.
"""
def __init__(self):
QTreeWidgetItem.__init__(self)
self.download_info = None
self._logger = logging.getLogger('TriblerGUI')
bar_container = QWidget()
bar_container.setLayout(QVBoxLayout())
bar_container.setStyleSheet("background-color: transparent;")
self.progress_slider = QProgressBar()
# We have to set a zero pixel border to get the background working on Mac.
self.progress_slider.setStyleSheet("""
QProgressBar {
background-color: white;
color: black;
font-size: 12px;
text-align: center;
border: 0px solid transparent;
}
QProgressBar::chunk {
background-color: #e67300;
}
""")
bar_container.layout().addWidget(self.progress_slider)
bar_container.layout().setContentsMargins(4, 4, 8, 4)
self.progress_slider.setAutoFillBackground(True)
self.bar_container = bar_container
def update_with_download(self, download):
self.download_info = download
self.update_item()
def get_raw_download_status(self):
return eval(self.download_info["status"])
def update_item(self):
self.setText(0, self.download_info["name"])
if self.download_info["name"] == u"<old version of your channel>":
itfont = QFont(self.font(0))
itfont.setItalic(True)
self.setFont(0, itfont)
else:
self.font(0).setItalic(False)
self.setText(1, format_size(float(self.download_info["size"])))
try:
self.progress_slider.setValue(int(self.download_info["progress"] * 100))
except RuntimeError:
self._logger.error("The underlying GUI widget has already been removed.")
if self.download_info["vod_mode"]:
self.setText(3, "Streaming")
else:
self.setText(3, DLSTATUS_STRINGS[eval(self.download_info["status"])])
self.setText(4, "%s (%s)" % (self.download_info["num_connected_seeds"], self.download_info["num_seeds"]))
self.setText(5, "%s (%s)" % (self.download_info["num_connected_peers"], self.download_info["num_peers"]))
self.setText(6, format_speed(self.download_info["speed_down"]))
self.setText(7, format_speed(self.download_info["speed_up"]))
self.setText(8, "%.3f" % float(self.download_info["ratio"]))
self.setText(9, "yes" if self.download_info["anon_download"] else "no")
self.setText(10, str(self.download_info["hops"]) if self.download_info["anon_download"] else "-")
self.setText(12, datetime.fromtimestamp(int(self.download_info["time_added"])).strftime('%Y-%m-%d %H:%M'))
eta_text = "-"
if self.get_raw_download_status() == DLSTATUS_DOWNLOADING:
eta_text = duration_to_string(self.download_info["eta"])
self.setText(11, eta_text)
def __lt__(self, other):
# The download info might not be available yet or there could still be loading QTreeWidgetItem
if not self.download_info or not isinstance(other, DownloadWidgetItem):
return True
elif not other.download_info:
return False
column = self.treeWidget().sortColumn()
if column == 1:
return float(self.download_info["size"]) > float(other.download_info["size"])
elif column == 2:
return int(self.download_info["progress"] * 100) > int(other.download_info["progress"] * 100)
elif column == 4:
return self.download_info["num_seeds"] > other.download_info["num_seeds"]
elif column == 5:
return self.download_info["num_peers"] > other.download_info["num_peers"]
elif column == 6:
return float(self.download_info["speed_down"]) > float(other.download_info["speed_down"])
elif column == 7:
return float(self.download_info["speed_up"]) > float(other.download_info["speed_up"])
elif column == 8:
return float(self.download_info["ratio"]) > float(other.download_info["ratio"])
elif column == 11:
#.........这里部分代码省略.........
示例7: percentajeWidget
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class percentajeWidget(QWidget):
def __init__(self,winParent, pose3d):
super(percentajeWidget, self).__init__()
self.winParent=winParent
self.map = cv2.imread("resources/images/mapgrannyannie.png", cv2.IMREAD_GRAYSCALE)
self.map = cv2.resize(self.map, (500, 500))
image = QtGui.QImage(self.map.data, self.map.shape[1], self.map.shape[0], self.map.shape[1], QtGui.QImage.Format_Indexed8);
self.pixmap = QtGui.QPixmap.fromImage(image)
self.pose3d = pose3d
self.percentajeHouse = 0
self.numPixels = self.calculatePixelsWhite()
self.numPixelsWalked = 0
vLayout = QVBoxLayout()
self.percentajeWalked()
self.Percentaje = QLabel("Percentaje: " + str(round(self.percentajeHouse, 3)) + ' %')
vLayout.addWidget(self.Percentaje, 0)
self.bar = QProgressBar()
self.bar.setValue(self.percentajeHouse)
st = "QProgressBar::chunk {background-color: #ff0000;}\n QProgressBar {border: 1px solid grey;border-radius: 2px;text-align: center;background: #eeeeee;}"
self.bar.setStyleSheet(st)
self.bar.setTextVisible(False)
vLayout.addWidget(self.Percentaje, 0)
vLayout.addWidget(self.bar, 0)
vSpacer = QSpacerItem(30, 80, QSizePolicy.Ignored, QSizePolicy.Ignored)
vLayout.addItem(vSpacer)
self.setLayout(vLayout)
def RTx(self, angle, tx, ty, tz):
RT = np.matrix([[1, 0, 0, tx], [0, math.cos(angle), -math.sin(angle), ty], [0, math.sin(angle), math.cos(angle), tz], [0,0,0,1]])
return RT
def RTy(self, angle, tx, ty, tz):
RT = np.matrix([[math.cos(angle), 0, math.sin(angle), tx], [0, 1, 0, ty], [-math.sin(angle), 0, math.cos(angle), tz], [0,0,0,1]])
return RT
def RTz(self, angle, tx, ty, tz):
RT = np.matrix([[math.cos(angle), -math.sin(angle), 0, tx], [math.sin(angle), math.cos(angle),0, ty], [0, 0, 1, tz], [0,0,0,1]])
return RT
def RTVacuum(self):
RTy = self.RTy(pi, 1, -1, 0)
return RTy
def calculatePixelsWhite(self):
# Calculating the 100% of the pixels that can be traversed
numPixels = 0
img = self.pixmap.toImage()
for i in range(0, self.map.shape[1]):
for j in range(0, self.map.shape[0]):
c = img.pixel(i,j)
color = QtGui.QColor(c).getRgbF()
if color == (1.0, 1.0, 1.0, 1.0):
numPixels = numPixels + 1
return numPixels
def calculatePercentaje(self):
percentaje = self.numPixelsWalked * 100 / self.numPixels
return percentaje
def percentajeWalked(self):
x = self.pose3d.getPose3d().x
y = self.pose3d.getPose3d().y
scale = 50
img = self.pixmap.toImage()
final_poses = self.RTVacuum() * np.matrix([[x], [y], [1], [1]]) * scale
i_init = int(-50/4+final_poses.flat[0] + self.map.shape[1]/2)
i_finish = int(50/4+final_poses.flat[0] + self.map.shape[1]/2)
j_init = int(-50/4+final_poses[1] + self.map.shape[0]/2)
j_finish = int(50/4+final_poses[1] + self.map.shape[0]/2)
for k in range(i_init, i_finish+1):
for l in range(j_init, j_finish+1):
c = img.pixel(k,l)
color = QtGui.QColor(c).getRgbF()
if color == (1.0, 1.0, 1.0, 1.0):
if self.map[k][l] != 128:
self.numPixelsWalked = self.numPixelsWalked + 1
self.map[k][l] = 128
self.percentajeHouse = self.calculatePercentaje()
def updateG(self):
self.percentajeWalked()
self.Percentaje.setText("Percentaje: " + str(round(self.percentajeHouse, 3)) + ' %')
self.bar.setValue(self.percentajeHouse)
self.update()
示例8: MediaItem
# 需要导入模块: from PyQt5.QtWidgets import QProgressBar [as 别名]
# 或者: from PyQt5.QtWidgets.QProgressBar import setStyleSheet [as 别名]
class MediaItem(QTreeWidgetItem):
UNDERLINE_CSS = 'text-decoration: underline;'
PLAY = QIcon.fromTheme("media-playback-start")
PAUSE = QIcon.fromTheme("media-playback-pause")
ERROR = QIcon.fromTheme("dialog-error")
def __init__(self, cue, view, **kwds):
super().__init__(**kwds)
self.cue = cue
self.media = cue.media
self.view = view
self.selected = False
self._accurate_time = False
self.actionsList = []
self.actionIndex = -1
self.init()
self.media_time = MediaTime(self.cue.media)
self.media_time.notify.connect(self.update_time)
self.cue.updated.connect(self.update_item)
self.media.duration.connect(self.update_duration)
self.media.on_play.connect(self.on_play)
self.media.on_stop.connect(self.reset_status)
self.media.on_pause.connect(self.on_pause)
self.media.interrupted.connect(self.reset_status)
self.media.eos.connect(self.reset_status)
self.media.error.connect(self.on_error)
self.update_item()
self.update_duration()
def init(self):
self.status = QLabel(self.view)
self.status.setStyleSheet('background: transparent;'
'padding-left: 20px;')
self.view.setItemWidget(self, 0, self.status)
self.timeProgress = QProgressBar(self.view)
self.timeProgress.setStyleSheet('background: transparent;'
'border-color: rgb(28, 66, 111);'
'margin: 2px;')
self.setTextAlignment(2, QtCore.Qt.AlignCenter)
self.update_duration()
def sizeHint():
size = self.sizeHint(3)
size.setHeight(size.height() - 4)
size.setWidth(size.width() - 4)
return size
self.timeProgress.sizeHint = sizeHint
self.view.setItemWidget(self, 3, self.timeProgress)
self.timeProgress.setValue(0)
self.timeProgress.setFormat('00:00:00')
def select(self):
self.selected = not self.selected
if self.selected:
self.setIcon(0, QIcon.fromTheme("media-record"))
else:
self.setIcon(0, QIcon())
def set_accurate_time(self, enable):
self._accurate_time = enable
self.update_duration()
def update_duration(self):
self.setText(2, strtime(self.media['duration'],
accurate=self._accurate_time))
self.timeProgress.setMaximum(self.media['duration'])
def update_item(self):
self.setText(1, self.cue['name'])
def update_time(self, time):
# If the given value is the duration or < 0 set the time to 0
if time == self.cue.media['duration'] or time < 0:
time = 0
# Set the progress-bar value
self.timeProgress.setValue(time)
# Show the time in the widget
self.timeProgress.setFormat(strtime(time,
accurate=self._accurate_time))
def on_play(self):
self.status.setPixmap(self.PLAY.pixmap(16, 16))
def on_pause(self):
self.status.setPixmap(self.PAUSE.pixmap(16, 16))
def on_error(self, media, error, details):
self.status.setPixmap(self.ERROR.pixmap(16, 16))
QDetailedMessageBox.dcritical(self.cue["name"], error, details)
#.........这里部分代码省略.........