-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTestWidget.py
More file actions
92 lines (76 loc) · 3.32 KB
/
Copy pathTestWidget.py
File metadata and controls
92 lines (76 loc) · 3.32 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#######################################################
#
# Copyright 2024 Pete Alexandrou
#
# Ported to Python from the original works in C++ by:
#
# Sintegrial Technologies (c) 2015
# https://sourceforge.net/projects/qroundprogressbar
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#######################################################
import sys
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QPalette
from PyQt6.QtWidgets import QApplication, QWidget
from qroundprogressbar import QRoundProgressBar
from ui_TestWidget import Ui_TestWidget
class TestWidget(QWidget, Ui_TestWidget):
def __init__(self, parent=None):
super(TestWidget, self).__init__(parent)
self.setupUi(self)
self.RoundBar1.setFormat('%v')
self.RoundBar1.setDecimals(0)
self.connectToSlider(self.RoundBar1)
self.RoundBar2.setNullPosition(QRoundProgressBar.PositionRight)
self.RoundBar2.setBarStyle(QRoundProgressBar.BarStyle.PIE)
self.connectToSlider(self.RoundBar2)
self.RoundBar3.setFormat('%m')
self.RoundBar3.setBarStyle(QRoundProgressBar.BarStyle.LINE)
self.connectToSlider(self.RoundBar3)
p1 = QPalette()
p1.setBrush(QPalette.ColorRole.AlternateBase, Qt.GlobalColor.black)
p1.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.yellow)
self.RoundBar4.setPalette(p1)
self.RoundBar4.setNullPosition(QRoundProgressBar.PositionLeft)
self.RoundBar4.setDecimals(0)
gradientPoints = [(0, Qt.GlobalColor.green), (0.5, Qt.GlobalColor.yellow), (1, Qt.GlobalColor.red)]
self.RoundBar4.setDataColors(gradientPoints)
self.connectToSlider(self.RoundBar4)
p2 = QPalette(p1)
p2.setBrush(QPalette.ColorRole.Base, Qt.GlobalColor.lightGray)
p2.setColor(QPalette.ColorRole.Text, Qt.GlobalColor.magenta)
p2.setColor(QPalette.ColorRole.Shadow, Qt.GlobalColor.green)
self.RoundBar5.setPalette(p2)
self.RoundBar5.setNullPosition(QRoundProgressBar.PositionRight)
self.RoundBar5.setBarStyle(QRoundProgressBar.BarStyle.PIE)
self.RoundBar5.setDataColors(gradientPoints)
self.connectToSlider(self.RoundBar5)
self.RoundBar6.setDecimals(2)
self.RoundBar6.setBarStyle(QRoundProgressBar.BarStyle.LINE)
self.RoundBar6.setOutlinePenWidth(18)
self.RoundBar6.setDataPenWidth(10)
self.connectToSlider(self.RoundBar6)
self.connectToSlider(self.RoundBar7)
def connectToSlider(self, bar: QRoundProgressBar):
bar.setRange(self.Slider.minimum(), self.Slider.maximum())
bar.setValue(self.Slider.value())
self.Slider.valueChanged.connect(bar.setValue)
if __name__ == '__main__':
app = QApplication(sys.argv)
widget = TestWidget()
widget.show()
sys.exit(app.exec())