-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRoundProgressBar.py
More file actions
946 lines (750 loc) · 27.6 KB
/
RoundProgressBar.py
File metadata and controls
946 lines (750 loc) · 27.6 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
#############################################################################################
# CREATOR: ANJAL.P #
# ON: 2020 SEP. #
# AIM: To Extend the capability of the PySide2 and PyQt5 Python library with easy to #
# use extension containing commonly used widgets which is not natively supported #
# by the Qt Frame work (or at least for Python version of Qt). #
# VERSION: v1.0.0 #
# NOTES: CLASS : RoundProgressBar : Can be accessed by : importing #
# from PySide2extn.RoundProgressBar import roundProgressBar #
# REFER: Github: #
# DOCUMENTATION: #
#############################################################################################
from PySide6 import QtWidgets
from PySide6.QtCore import Qt, QSize
from PySide6.QtGui import QColor, QPainter, QPen, QPaintEvent, QFont
class roundProgressBar(QtWidgets.QWidget):
def __init__(self, parent=None):
super(roundProgressBar, self).__init__(parent)
self.positionX = 0
self.positionY = 0
self.posFactor = 0
self.rpb_minimumSize = (0, 0)
self.rpb_maximumSize = (0, 0)
self.rpb_dynamicMin = True
self.rpb_dynamicMax = True
self.rpb_Size = 0
self.sizeFactor = 0
self.rpb_maximum = 100
self.rpb_minimum = 0
self.rpb_type = self.barStyleFlags.Donet
self.startPosition = self.startPosFlags.North
self.rpb_direction = self.rotationFlags.Clockwise
self.rpb_textType = self.textFlags.Percentage
self.rpb_textColor = (0, 159, 227)
self.rpb_textWidth = self.rpb_Size / 8
self.rpb_textFont = 'Segoe UI'
self.rpb_textValue = '12%'
self.rpb_textRatio = 8
self.textFactorX = 0
self.textFactorY = 0
self.dynamicText = True
self.rpb_textActive = True
self.lineWidth = 5
self.pathWidth = 5
self.rpb_lineStyle = self.lineStyleFlags.SolidLine
self.rpb_lineCap = self.lineCapFlags.SquareCap
self.lineColor = (0, 159, 227)
self.pathColor = (218, 218, 218)
self.rpb_circleColor = (218, 218, 218)
self.rpb_circleRatio = 0.8
self.rpb_circlePosX = 0
self.rpb_circlePosY = 0
self.rpb_pieColor = (200, 200, 200)
self.rpb_pieRatio = 1
self.rpb_piePosX = 0
self.rpb_piePosY = 0
self.rpb_value = -45 * 16
if self.rpb_dynamicMin:
self.setMinimumSize(QSize(self.lineWidth * 6 + self.pathWidth * 6, self.lineWidth * 6 + self.pathWidth * 6))
# ------------------------------------------------------CLASS ENUMERATORS
class lineStyleFlags:
SolidLine = Qt.SolidLine
DotLine = Qt.DotLine
DashLine = Qt.DashLine
class lineCapFlags:
SquareCap = Qt.SquareCap
RoundCap = Qt.RoundCap
class barStyleFlags:
Donet = 0
Line = 1
Pie = 2
Pizza = 3
Hybrid1 = 4
Hybrid2 = 5
class rotationFlags:
Clockwise = -1
AntiClockwise = 1
class textFlags:
Value = 0
Percentage = 1
class startPosFlags:
North = 90 * 16
South = -90 * 16
East = 0 * 16
West = 180 * 16
# METHODS FOR CHANGING THE PROPERTY OF THE ROUND-PROGRESSBAR :SOLTS
def rpb_setMinimumSize(self, width, height):
"""
Minimum Size of the Widget
...
Parameters
--------------
width : int
width of the Widget
height : int
height of the Widget
Raises
--------------
Exception : Sorry Width/Height should be an int
"""
if not isinstance(width, int) or not isinstance(height, int):
raise Exception('Sorry Width/Height should be an int')
self.rpb_dynamicMin = False
self.setMinimumSize(width, height)
self.rpb_minimumSize = (width, height)
self.update()
def rpb_setMaximumSize(self, width, height):
"""
Maximum Size of the Widget
...
Parameters
--------------
width : int
width of the Widget
height : int
height of the Widget
Raises
--------------
Exception : Sorry Width/Height should be an int
"""
if not isinstance(width, int) or not isinstance(height, int):
raise Exception('Sorry Width/Height should be an int')
self.rpb_dynamicMax = False
self.setMaximumSize(width, height)
self.rpb_maximumSize = (width, height)
self.update()
def rpb_setMaximum(self, maximum):
"""
Maximum Value of the Progressbar
...
Parameters
--------------
maximum : int
Maximum value of the round progress bar
Raises
--------------
Exception : Maximum and Minimum cannot be the Same
"""
if self.rpb_minimum == maximum: # FOR AVOIDING DIVISION BY ZERO ERROR IN FUTURE
raise Exception("Maximum and Minimum cannot be the Same")
if self.rpb_maximum != maximum:
self.rpb_maximum = maximum
self.update()
def rpb_setMinimum(self, minimum):
"""
Minimum Value of the Progressbar
...
Parameters
--------------
minimum : int
Minimum value of the round progress bar
Raises
--------------
Exception : Maximum and Minimum cannot be the Same
"""
if self.rpb_maximum == minimum: # FOR AVOIDING DIVISION BY ZERO ERROR IN FUTURE
raise Exception("Maximum and Minimum cannot be the Same")
if self.rpb_minimum != minimum:
self.rpb_minimum = minimum
self.update()
def rpb_setRange(self, maximum, minimum):
"""
Range include the maximum and the minimum in one go.
...
Parameters
--------------
maximum : int
Maximum value of the round progress bar
minimum : int
Minimum value for the round progress bar
Raises
--------------
none
"""
if minimum > maximum:
maximum, minimum = minimum, maximum
if self.rpb_maximum != maximum:
self.rpb_maximum = maximum
if self.rpb_minimum != minimum:
self.rpb_minimum = minimum
self.update()
def rpb_setInitialPos(self, pos):
"""
Starting position of the round progress bar
...
Parameters
--------------
pos : String
Position string: 'North', 'South', 'East' and 'West'
Raises
--------------
ValueError : Maximum and Minimum cannot be the Same
"""
if pos == 'North':
self.startPosition = self.startPosFlags.North
elif pos == 'South':
self.startPosition = self.startPosFlags.South
elif pos == 'East':
self.startPosition = self.startPosFlags.East
elif pos == 'West':
self.startPosition = self.startPosFlags.West
else:
raise Exception("Initial Position String can be: 'South', 'North'")
def rpb_setValue(self, value):
"""
Set progress value
...
Parameters
--------------
value : int
The value of the progress bar in int. The value should be: min<=value<=max
Raises
--------------
none
"""
if self.rpb_value != value:
if value >= self.rpb_maximum:
roundProgressBar.convertInputValue(self, self.rpb_maximum)
elif value < self.rpb_minimum:
roundProgressBar.convertInputValue(self, self.rpb_minimum)
else:
roundProgressBar.convertInputValue(self, value)
self.update()
def rpb_reset(self):
"""
Reset the progress bar to 0%
...
Parameters
--------------
Raises
--------------
none
"""
roundProgressBar.convertInputValue(self, self.rpb_minimum)
self.update()
def rpb_setGeometry(self, posX, posY):
"""
Set the X and Y position of the round progress bar.
...
Parameters
--------------
posX : int
The position of the round progress bar in int for X axis.
posY : int
The position of the round progress bar in int for Y axis.
Raises
--------------
none
"""
if self.positionX != posX:
self.positionX = posX
if self.positionY != posY:
self.positionY = posY
self.update()
def rpb_setLineWidth(self, width):
"""
Line Width of the line in round progress bar.
...
Parameters
--------------
width: int
Line width corresponding to the width in px.
Raises
--------------
Exception: Line Width should be in int
"""
if not isinstance(width, int):
raise Exception('Line Width should be in int')
if self.lineWidth != width:
self.lineWidth = width
self.update()
def rpb_setLineColor(self, rgb):
"""
Line Color of the progress bar.
...
Parameters
--------------
rgb: tuple: (R, G, B)
Color is passed as a tuple of values for red, blue and green in the order: (R, G, B)
Raises
--------------
Exception: Line Color accepts a tuple: (R, G, B).
"""
if not isinstance(rgb, tuple):
raise Exception("Line Color accepts a tuple: (R, G, B).")
if self.lineColor != rgb:
self.lineColor = rgb
self.update()
def rpb_setPathColor(self, rgb):
"""
Path Color settings.
...
Parameters
--------------
rgb: tuple: (R, G, B)
Color is passed as a tuple of values for red, blue and green in the order: (R, G, B)
Raises
--------------
Exception: Path Color accepts a tuple: (R, G, B).
"""
if not isinstance(rgb, tuple):
raise Exception("Path Color accepts a tuple: (R, G, B).")
if self.pathColor != rgb:
self.pathColor = rgb
self.update()
def rpb_setPathWidth(self, width):
"""
Path width settings.
...
Parameters
--------------
width: int
Width of the path in px
Raises
--------------
Exception: Line Width should be in int
"""
if not isinstance(width, int):
raise Exception('Path Width should be in int')
if self.pathWidth != width:
self.pathWidth = width
self.update()
def rpb_setDirection(self, direction):
"""
Direction of rotation of the progress bar.
...
Parameters
--------------
direction: string
string can be: 'AntiClockwise' or 'Clockwise'. Default: 'Clockwise'.
Raises
--------------
Exception: Direction can only be: 'Clockwise' and 'AntiClockwise'
"""
if direction == 'Clockwise' or direction == -1:
self.rpb_direction = self.rotationFlags.Clockwise
elif direction == 'AntiClockwise' or direction == 1:
self.rpb_direction = self.rotationFlags.AntiClockwise
else:
raise Exception("Direction can only be: 'Clockwise' and 'AntiClockwise' and Not: " + str(direction))
self.update()
def rpb_setBarStyle(self, style):
"""
Bar Style of the progress bar.
...
Parameters
--------------
style: String
String of the styles of the progress bar: 'Donet', 'Pie', 'line', 'Hybrid1', 'Hybrid2', 'Pizza'
Raises
--------------
Exception: Round Progress Bar has only the following styles: 'Line', 'Donet', 'Hybrid1', 'Pizza', 'Pie' and 'Hybrid2'
"""
if style == 'Donet':
self.rpb_type = self.barStyleFlags.Donet
elif style == 'Line':
self.rpb_type = self.barStyleFlags.Line
elif style == 'Pie':
self.rpb_type = self.barStyleFlags.Pie
elif style == 'Pizza':
self.rpb_type = self.barStyleFlags.Pizza
elif style == 'Hybrid1':
self.rpb_type = self.barStyleFlags.Hybrid1
elif style == 'Hybrid2':
self.rpb_type = self.barStyleFlags.Hybrid2
else:
raise Exception(
"Round Progress Bar has only the following styles: 'Line', 'Donet', 'Hybrid1', 'Pizza', 'Pie' and "
"'Hybrid2'")
self.update()
def rpb_setLineStyle(self, style):
"""
Line Style setting.
...
Parameters
--------------
style: String
Line style: 'DotLine', 'DashLine', 'SolidLine', passed as a string.
Raises
--------------
none
"""
if style == 'SolidLine':
self.rpb_lineStyle = self.lineStyleFlags.SolidLine
elif style == 'DotLine':
self.rpb_lineStyle = self.lineStyleFlags.DotLine
elif style == 'DashLine':
self.rpb_lineStyle = self.lineStyleFlags.DashLine
else:
self.rpb_lineStyle = self.lineStyleFlags.SolidLine
def rpb_setLineCap(self, cap):
"""
Line Cap setting.
...
Parameters
--------------
cap: String
Cap is the end point of a stroke. It can be: 'RoundCap' or 'SquareCap'
Raises
--------------
none
"""
if cap == 'SquareCap':
self.rpb_lineCap = self.lineCapFlags.SquareCap
elif cap == 'RoundCap':
self.rpb_lineCap = self.lineCapFlags.RoundCap
def rpb_setTextColor(self, rgb):
"""
Text color of the text inside the progress bar
...
Parameters
--------------
rgb: tuple
Color of the text in the format: (R, G, B)
Raises
--------------
none
"""
if self.rpb_textColor != rgb:
self.rpb_textColor = rgb
self.update()
def rpb_setTextFont(self, font):
"""
Font of the text inside the round progress bar
...
Parameters
--------------
font: str
Name of the font in string
Raises
--------------
none
"""
if self.rpb_textFont != font:
self.rpb_textFont = font
self.update()
def rpb_setTextFormat(self, textTyp):
"""
Text formatter i.e. the value or the percentage.
...
Parameters
--------------
textTyp: str
'value', 'percentage'
Raises
--------------
none
"""
if textTyp == 'Value':
self.rpb_textType = self.textFlags.Value
elif textTyp == 'Percentage':
self.rpb_textType = self.textFlags.Percentage
else:
self.rpb_textType = self.textFlags.Percentage
def rpb_setTextRatio(self, ratio):
"""
Text ratio with respect to the size of the progress bar.
...
Parameters
--------------
ratio: int
In number from 3 to 50 corresponding to 1/3 or 1/50 the size of the roundprogressbar.
Raises
--------------
none
"""
if self.rpb_textRatio != ratio:
if ratio < 3:
ratio = 3
elif ratio > 50:
ratio = 50
self.rpb_textRatio = ratio
self.update()
def rpb_setTextWidth(self, width):
"""
Text Width.
...
Parameters
--------------
width: int
Text constant width. Will not change during the widget resize.
Raises
--------------
none
"""
self.dynamicText = False
if width > 0:
self.rpb_textWidth = width
self.update()
def rpb_setCircleColor(self, rgb):
"""
Circle color fill inside the circle.
...
Parameters
--------------
rgb: tuple
The color of the circle in the tuple corresponding to the (R, G, B).
Raises
--------------
none
"""
if self.rpb_circleColor != rgb:
self.rpb_circleColor = rgb
self.update()
def rpb_setCircleRatio(self, ratio):
"""
Circle ration corresponding to the round progress bar.
...
Parameters
--------------
ratio: int
Integer corresponding to the size of the progress bar to that of the round progress bar.
Raises
--------------
none
"""
if self.rpb_circleRatio != ratio:
self.rpb_circleRatio = ratio
self.update()
def rpb_setPieColor(self, rgb):
"""
Pie color inside the fill.
...
Parameters
--------------
rgb: tuple
Tuple consist in format (R, G, B). Same as color setting to Line.
Raises
--------------
none
"""
if self.rpb_pieColor != rgb:
self.rpb_pieColor = rgb
self.update()
def rpb_setPieRatio(self, ratio):
"""
Pie Ratio
...
Parameters
--------------
ratio: int
Ratio corresponding to the size between the roundprogressbar and the pie size.
Raises
--------------
none
"""
if self.rpb_pieRatio != ratio:
self.rpb_pieRatio = ratio
self.update()
def rpb_enableText(self, enable):
"""
Makes the Text visible/Hidden
...
Parameters
--------------
enable: bool
True: Text visible, False: Text invisible.
Raises
--------------
none
"""
if enable:
self.rpb_textActive = enable
else:
self.rpb_textActive = enable
self.update()
# ------------------------------------------------------METHODS FOR GETTING THE PROPERTY OF ROUNDPROGRESSBAR SLOTS
def rpb_getSize(self):
"""
Get the present size of the progress bar.
...
Returns
--------------
Return the size of the round progress bar in int.
"""
return self.rpb_Size
def rpb_getValue(self):
"""
Present value of the progress bar.
...
Returns
--------------
int corresponding to the present progress bar value.
"""
return self.rpb_value / 16
def rpb_getRange(self):
"""
Progress bar range.
...
Returns
--------------
tuple consisting of minimum and maximum as elements.
"""
return self.rpb_minimum, self.rpb_maximum
def rpb_getTextWidth(self):
"""
Text width of the present text in the central of the widget.
...
Returns
--------------
int corresponding to the width of the text
"""
return self.rpb_textWidth
# ENGINE: WHERE ALL THE REAL STUFF TAKE PLACE: WORKING OF THE ROUNDPROGRESSBAR
def rpb_MinimumSize(self, dynamicMax, minimum, maximum):
"""
Minimum size calculating code: Takes consideration of the width of the line/path/circle/pie and the user defined
width and also the size of the frame/window of the application.
"""
rpb_Height = self.height()
rpb_Width = self.width()
if dynamicMax:
if rpb_Width >= rpb_Height >= minimum[1]:
self.rpb_Size = rpb_Height
elif rpb_Height > rpb_Width >= minimum[0]:
self.rpb_Size = rpb_Width
else:
if rpb_Width >= rpb_Height and rpb_Height <= maximum[1]:
self.rpb_Size = rpb_Height
elif rpb_Width < rpb_Height and rpb_Width <= maximum[0]:
self.rpb_Size = rpb_Width
def convertInputValue(self, value):
"""
CONVERTS ANY INPUT VALUE TO THE 0*16-360*16 DEGREE REFERENCE OF THE QPainter.drawArc NEEDED.
"""
self.rpb_value = ((value - self.rpb_minimum) / (self.rpb_maximum - self.rpb_minimum)) * 360 * 16
self.rpb_value = self.rpb_direction * self.rpb_value
if self.rpb_textType == roundProgressBar.textFlags.Percentage:
self.rpb_textValue = str(
round(((value - self.rpb_minimum) / (self.rpb_maximum - self.rpb_minimum)) * 100)) + "%"
else:
self.rpb_textValue = str(value)
# SINCE THE THICKNESS OF THE LINE OR THE PATH CAUSES THE WIDGET TO WRONGLY FIT INSIDE THE SIZE OF THE WIDGET DESIGNED IN THE
# QTDESIGNER, THE CORRECTION FACTOR IS NECESSARILY CALLED THE GEOMETRY FACTOR, WHICH CALCULATE THE TWO FACTORS CALLED THE
# self.posFactor AND THE self.sizeFactor, CALCULATION THIS IS NECESSARY AS THE
def geometryFactor(self):
if self.lineWidth > self.pathWidth:
self.posFactor = self.lineWidth / 2 + 1
self.sizeFactor = self.lineWidth + 1
else:
self.posFactor = self.pathWidth / 2 + 1
self.sizeFactor = self.pathWidth + 1
def rpb_textFactor(self):
if self.dynamicText:
self.rpb_textWidth = self.rpb_Size / self.rpb_textRatio
self.textFactorX = self.posFactor + (self.rpb_Size - self.sizeFactor) / 2 - self.rpb_textWidth * 0.75 * (
len(self.rpb_textValue) / 2)
self.textFactorY = self.rpb_textWidth / 2 + self.rpb_Size / 2
def rpb_circleFactor(self):
self.rpb_circlePosX = self.positionX + self.posFactor + (self.rpb_Size * (1 - self.rpb_circleRatio)) / 2
self.rpb_circlePosY = self.positionY + self.posFactor + (self.rpb_Size * (1 - self.rpb_circleRatio)) / 2
def rpb_pieFactor(self):
self.rpb_piePosX = self.positionX + self.posFactor + (self.rpb_Size * (1 - self.rpb_pieRatio)) / 2
self.rpb_piePosY = self.positionY + self.posFactor + (self.rpb_Size * (1 - self.rpb_pieRatio)) / 2
def paintEvent(self, event: QPaintEvent):
# THIS BELOW CODE AMKE SURE THAT THE SIZE OF THE ROUNDPROGRESSBAR DOES NOT REDUCE TO ZERO WHEN THE USER RESIZES THE WINDOW
if self.rpb_dynamicMin:
self.setMinimumSize(QSize(self.lineWidth * 6 + self.pathWidth * 6, self.lineWidth * 6 + self.pathWidth * 6))
roundProgressBar.rpb_MinimumSize(self, self.rpb_dynamicMax, self.rpb_minimumSize, self.rpb_maximumSize)
roundProgressBar.geometryFactor(self)
roundProgressBar.rpb_textFactor(self)
roundProgressBar.rpb_circleFactor(self)
roundProgressBar.rpb_pieFactor(self)
if self.rpb_type == 0: # DONET TYPE
roundProgressBar.pathComponent(self)
roundProgressBar.lineComponent(self)
roundProgressBar.textComponent(self)
elif self.rpb_type == 1: # LINE TYPE
roundProgressBar.lineComponent(self)
roundProgressBar.textComponent(self)
elif self.rpb_type == 2: # Pie
roundProgressBar.pieComponent(self)
roundProgressBar.textComponent(self)
elif self.rpb_type == 3: # PIZZA
roundProgressBar.circleComponent(self)
roundProgressBar.lineComponent(self)
roundProgressBar.textComponent(self)
elif self.rpb_type == 4: # HYBRID1
roundProgressBar.circleComponent(self)
roundProgressBar.pathComponent(self)
roundProgressBar.lineComponent(self)
roundProgressBar.textComponent(self)
elif self.rpb_type == 5: # HYBRID2
roundProgressBar.pieComponent(self)
roundProgressBar.lineComponent(self)
roundProgressBar.textComponent(self)
def lineComponent(self):
linePainter = QPainter(self)
linePainter.setRenderHint(QPainter.Antialiasing)
penLine = QPen()
penLine.setStyle(self.rpb_lineStyle)
penLine.setWidth(self.lineWidth)
penLine.setBrush(QColor(self.lineColor[0], self.lineColor[1], self.lineColor[2]))
penLine.setCapStyle(self.rpb_lineCap)
penLine.setJoinStyle(Qt.RoundJoin)
linePainter.setPen(penLine)
linePainter.drawArc(self.positionX + self.posFactor, self.positionY + self.posFactor,
self.rpb_Size - self.sizeFactor, self.rpb_Size - self.sizeFactor, self.startPosition,
self.rpb_value)
linePainter.end()
def pathComponent(self):
pathPainter = QPainter(self)
pathPainter.setRenderHint(QPainter.Antialiasing)
penPath = QPen()
penPath.setStyle(Qt.SolidLine)
penPath.setWidth(self.pathWidth)
penPath.setBrush(QColor(self.pathColor[0], self.pathColor[1], self.pathColor[2]))
penPath.setCapStyle(Qt.RoundCap)
penPath.setJoinStyle(Qt.RoundJoin)
pathPainter.setPen(penPath)
pathPainter.drawArc(self.positionX + self.posFactor, self.positionY + self.posFactor,
self.rpb_Size - self.sizeFactor, self.rpb_Size - self.sizeFactor, 0, 360 * 16)
pathPainter.end()
def textComponent(self):
if self.rpb_textActive:
textPainter = QPainter(self)
penText = QPen()
penText.setColor(QColor(self.rpb_textColor[0], self.rpb_textColor[1], self.rpb_textColor[2]))
textPainter.setPen(penText)
fontText = QFont()
fontText.setFamily(self.rpb_textFont)
fontText.setPointSize(self.rpb_textWidth)
textPainter.setFont(fontText)
textPainter.drawText(self.positionX + self.textFactorX, self.positionY + self.textFactorY,
self.rpb_textValue)
textPainter.end()
def circleComponent(self):
circlePainter = QPainter(self)
penCircle = QPen()
penCircle.setWidth(0)
penCircle.setColor(QColor(self.rpb_circleColor[0], self.rpb_circleColor[1], self.rpb_circleColor[2]))
circlePainter.setRenderHint(QPainter.Antialiasing)
circlePainter.setPen(penCircle)
circlePainter.setBrush(QColor(self.rpb_circleColor[0], self.rpb_circleColor[1], self.rpb_circleColor[2]))
circlePainter.drawEllipse(self.rpb_circlePosX, self.rpb_circlePosY,
int((self.rpb_Size - self.sizeFactor) * self.rpb_circleRatio),
int((self.rpb_Size - self.sizeFactor) * self.rpb_circleRatio))
def pieComponent(self):
piePainter = QPainter(self)
penPie = QPen()
penPie.setWidth(0)
penPie.setColor(QColor(self.rpb_pieColor[0], self.rpb_pieColor[1], self.rpb_pieColor[2]))
piePainter.setRenderHint(QPainter.Antialiasing)
piePainter.setPen(penPie)
piePainter.setBrush(QColor(self.rpb_pieColor[0], self.rpb_pieColor[1], self.rpb_pieColor[2]))
piePainter.drawPie(self.rpb_piePosX, self.rpb_piePosY, (self.rpb_Size - self.sizeFactor) * self.rpb_pieRatio,
(self.rpb_Size - self.sizeFactor) * self.rpb_pieRatio, self.startPosition, self.rpb_value)
# ------------------------------------------------------
if __name__ == "__main__":
print("Try Import.")