Skip to content

Commit

Permalink
Enhance bar indicator for 100% value separate from max
Browse files Browse the repository at this point in the history
  • Loading branch information
joco-nz committed Aug 24, 2021
1 parent 5c44d8f commit 90ecba1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion qtpyvcp/widgets/base_widgets/bar_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, parent=None):
self._value = 100
self._minimum = 0.0
self._maximum = 100.0
self._value_at_100_percent = 100.0
self._format = '{p}%'

self._text_color = QColor(0, 0, 0)
Expand Down Expand Up @@ -226,9 +227,18 @@ def orientation(self, orient):
self.adjustTransformation()
self.update()

@Property(float)
def valueAt100Percent(self):
return self._value_at_100_percent

@valueAt100Percent.setter
def valueAt100Percent(self, value_at):
self._value_at_100_percent = value_at
self.update()

def text(self):
values = {'v': self._value,
'p': int((self._value * 100 / self._maximum) + .5)}
'p': int((self._value * 100 / self._value_at_100_percent) + .5)}
try:
return self.format.encode("utf-8").format(**values)
except:
Expand Down

0 comments on commit 90ecba1

Please sign in to comment.