Mercurial > fife-parpg
comparison engine/extensions/pychan/widgets/slider.py @ 248:a2d5e2721489
widgets.py split up.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 26 Mar 2009 16:20:16 +0000 |
parents | |
children | 51cc05d862f2 |
comparison
equal
deleted
inserted
replaced
247:040387b7167f | 248:a2d5e2721489 |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from common import * | |
4 from widget import Widget | |
5 | |
6 class Slider(Widget): | |
7 """ A slider widget | |
8 | |
9 Use a callback to read out the slider value every time the marker | |
10 is moved. | |
11 | |
12 New Attributes | |
13 ============== | |
14 | |
15 - orientation: 1 = horizontal, 0=vertical | |
16 - scale_start: float: default 0.0 | |
17 - scale_end: float: default 1.0 | |
18 | |
19 FIXME: | |
20 - set new attributes for marker & step length, value | |
21 - update docstrings | |
22 """ | |
23 | |
24 HORIZONTAL = fife.Slider.HORIZONTAL | |
25 VERTICAL = fife.Slider.VERTICAL | |
26 | |
27 ATTRIBUTES = Widget.ATTRIBUTES + [IntAttr('orientation'), FloatAttr('scale_start'), FloatAttr('scale_end')] | |
28 | |
29 def __init__(self, scaleStart=0.0, scaleEnd=1.0, orientation=HORIZONTAL, **kwargs): | |
30 self.real_widget = fife.Slider(scaleStart, scaleEnd) | |
31 self.orientation = orientation | |
32 self.setOrientation(self.orientation) | |
33 super(Slider, self).__init__(**kwargs) | |
34 | |
35 def _setScale(self, start, end): | |
36 """setScale(self, double scaleStart, double scaleEnd)""" | |
37 if type(start) != float: | |
38 raise RuntimeError("Slider expects float for start scale") | |
39 if type(end) != float: | |
40 raise RuntimeError("Slider expects float for end scale") | |
41 self.real_widget.setScale(start, end) | |
42 | |
43 def getScaleStart(self): | |
44 """getScaleStart(self) -> double""" | |
45 return self.real_widget.getScaleStart() | |
46 | |
47 def setScaleStart(self, start): | |
48 """setScaleStart(self, double scaleStart)""" | |
49 if type(start) != float: | |
50 raise RuntimeError("Slider expects float for start scale") | |
51 self.real_widget.setScaleStart(start) | |
52 scale_start = property(getScaleStart, setScaleStart) | |
53 | |
54 def getScaleEnd(self): | |
55 """getScaleEnd(self) -> double""" | |
56 return self.real_widget.getScaleEnd() | |
57 | |
58 def setScaleEnd(self, end): | |
59 """setScaleEnd(self, double scaleEnd)""" | |
60 if type(end) != float: | |
61 raise RuntimeError("Slider expects float for end scale") | |
62 self.real_widget.setScaleEnd(end) | |
63 scale_end = property(getScaleEnd, setScaleEnd) | |
64 | |
65 def getValue(self): | |
66 """getValue(self) -> double""" | |
67 return self.real_widget.getValue() | |
68 | |
69 def setValue(self, value): | |
70 """setValue(self, double value)""" | |
71 if type(value) != float: | |
72 raise RuntimeError("Slider only accepts float values") | |
73 self.real_widget.setValue(value) | |
74 | |
75 def setMarkerLength(self, length): | |
76 """setMarkerLength(self, int length)""" | |
77 if type(length) != int: | |
78 raise RuntimeError("Slider only accepts int for Marker lenght") | |
79 self.real_widget.setMarkerLength(length) | |
80 | |
81 def getMarkerLength(self): | |
82 """getMarkerLength(self) -> int""" | |
83 return self.real_widget.getMarkerLength() | |
84 | |
85 def setOrientation(self, orientation): | |
86 """setOrientation(self, Orientation orientation)""" | |
87 self.real_widget.setOrientation(orientation) | |
88 | |
89 def getOrientation(self): | |
90 """getOrientation(self) -> int""" | |
91 return self.real_widget.getOrientation() | |
92 orientation = property(getOrientation, setOrientation) | |
93 | |
94 def setStepLength(self, length): | |
95 """setStepLength(self, double length)""" | |
96 if type(length) != float: | |
97 raise RuntimeError("Slider only accepts floats for step length") | |
98 self.real_widget.setStepLength(length) | |
99 | |
100 def getStepLength(self): | |
101 """getStepLength(self) -> double""" | |
102 return self.real_widget.getStepLength() |