forked from timothyhalim/Render-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_progressbar.py
68 lines (52 loc) · 2.02 KB
/
test_progressbar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sys
from random import randint
from PySide2.QtGui import QColor, QPalette, Qt
from PySide2.QtWidgets import QApplication, QDialog, QHBoxLayout, QLabel, QVBoxLayout, QWidget
from gui.QSS import Stylesheet, getNukePalette
class Chunk(QWidget):
def __init__(self, text=""):
super().__init__()
self.setAutoFillBackground(True)
self.update_color(rgb=(randint(0,255),randint(0,255),randint(0,255)))
self.setAttribute(Qt.WA_StyledBackground, True)
self.setToolTip(str(text))
def update_color(self, rgb):
self.setStyleSheet(f'background-color: rgb({rgb[0]}, {rgb[1]}, {rgb[2]})')
class ChunkBar(QWidget):
def __init__(self, parent = None, chunks=200):
super().__init__(parent)
self.frame_layout = QHBoxLayout(self)
self.frame_layout.setMargin(0)
self.frame_layout.setSpacing(0)
self.chunks = [Chunk(x) for x in range(chunks)]
for chunk in self.chunks:
self.frame_layout.addWidget(chunk)
class CustomProgressBar(QWidget):
def __init__(self, size=18):
super().__init__()
self.layout = QHBoxLayout(self)
self.layout.setMargin(0)
self.statusIcon = QLabel("Ico")
self.statusIcon.setMaximumWidth(size)
self.statusIcon.setMinimumWidth(size)
self.statusLabel = QLabel("100.99%")
self.statusLabel.setMaximumWidth(50)
self.statusLabel.setMinimumWidth(50)
self.bar = ChunkBar(chunks=100)
self.layout.addWidget(self.statusIcon)
self.layout.addWidget(self.statusLabel)
self.layout.addWidget(self.bar)
class Dialog(QDialog):
def __init__(self):
super().__init__()
self.setStyleSheet(Stylesheet)
self.setPalette(getNukePalette())
self.layout = QVBoxLayout(self)
self.layout.addWidget(CustomProgressBar())
self.show()
if __name__ == '__main__':
# try:
app = QApplication(sys.argv)
app.setStyle("Fusion")
w = Dialog()
app.exec_()