Commit before breaking everything
[matches/honours.git] / research / transmission_spectroscopy / simulator / pgu-0.18 / build / lib / pgu / gui / misc.py
1 from .const import *
2 from . import widget
3 from . import pguglobals
4
5 class ProgressBar(widget.Widget):
6     """A progress bar widget.
7     
8     Example:
9         w = gui.ProgressBar(0,0,100)
10         w.value = 25
11
12     """
13
14     _value = None
15
16     def __init__(self,value,min,max,**params):
17         params.setdefault('cls','progressbar')
18         widget.Widget.__init__(self,**params)
19         self.min,self.max,self.value = min,max,value
20     
21     def paint(self,s):
22         if (self.value != None):
23             r = pygame.rect.Rect(0,0,self.rect.w,self.rect.h)
24             r.w = r.w*(self.value-self.min)/(self.max-self.min)
25             self.bar = r
26             pguglobals.app.theme.render(s,self.style.bar,r)
27         
28     @property
29     def value(self):
30         return self._value
31
32     @value.setter
33     def value(self, val):
34         val = int(val)
35         val = max(val, self.min)
36         val = min(val, self.max)
37         oldval = self._value
38         self._value = val
39         if (oldval != val):
40             self.send(CHANGE)
41             self.repaint()
42
43

UCC git Repository :: git.ucc.asn.au