Mercurial > fife-parpg
comparison engine/python/fife/extensions/pychan/widgets/slider.py @ 378:64738befdf3b
bringing in the changes from the build_system_rework branch in preparation for the 0.3.0 release. This commit will require the Jan2010 devkit. Clients will also need to be modified to the new way to import fife.
author | vtchill@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 11 Jan 2010 23:34:52 +0000 |
parents | |
children | bab6eeec278c |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 # #################################################################### | |
4 # Copyright (C) 2005-2009 by the FIFE team | |
5 # http://www.fifengine.de | |
6 # This file is part of FIFE. | |
7 # | |
8 # FIFE is free software; you can redistribute it and/or | |
9 # modify it under the terms of the GNU Lesser General Public | |
10 # License as published by the Free Software Foundation; either | |
11 # version 2.1 of the License, or (at your option) any later version. | |
12 # | |
13 # This library is distributed in the hope that it will be useful, | |
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 # Lesser General Public License for more details. | |
17 # | |
18 # You should have received a copy of the GNU Lesser General Public | |
19 # License along with this library; if not, write to the | |
20 # Free Software Foundation, Inc., | |
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
22 # #################################################################### | |
23 | |
24 from common import * | |
25 from widget import Widget | |
26 | |
27 class Slider(Widget): | |
28 """ A slider widget | |
29 | |
30 Use a callback to read out the slider value every time the marker | |
31 is moved. | |
32 | |
33 New Attributes | |
34 ============== | |
35 | |
36 - orientation: 1 = horizontal, 0=vertical | |
37 - scale_start: float: default 0.0 | |
38 - scale_end: float: default 1.0 | |
39 | |
40 FIXME: | |
41 - set new attributes for marker & step length, value | |
42 - update docstrings | |
43 """ | |
44 | |
45 HORIZONTAL = fife.Slider.HORIZONTAL | |
46 VERTICAL = fife.Slider.VERTICAL | |
47 | |
48 ATTRIBUTES = Widget.ATTRIBUTES + [IntAttr('orientation'), FloatAttr('scale_start'), FloatAttr('scale_end')] | |
49 DEFAULT_HEXPAND = 1 | |
50 DEFAULT_VEXPAND = 0 | |
51 | |
52 def __init__(self, scaleStart=0.0, scaleEnd=1.0, orientation=HORIZONTAL, min_size=(10,10),**kwargs): | |
53 self.real_widget = fife.Slider(scaleStart, scaleEnd) | |
54 self.orientation = orientation | |
55 self.setOrientation(self.orientation) | |
56 super(Slider, self).__init__(min_size=min_size,**kwargs) | |
57 | |
58 self.accepts_data = True | |
59 self._realSetData = self.setValue | |
60 self._realGetData = self.getValue | |
61 | |
62 def _setScale(self, start, end): | |
63 """setScale(self, double scaleStart, double scaleEnd)""" | |
64 if type(start) != float: | |
65 raise RuntimeError("Slider expects float for start scale") | |
66 if type(end) != float: | |
67 raise RuntimeError("Slider expects float for end scale") | |
68 self.real_widget.setScale(start, end) | |
69 | |
70 def getScaleStart(self): | |
71 """getScaleStart(self) -> double""" | |
72 return self.real_widget.getScaleStart() | |
73 | |
74 def setScaleStart(self, start): | |
75 """setScaleStart(self, double scaleStart)""" | |
76 if type(start) != float: | |
77 raise RuntimeError("Slider expects float for start scale") | |
78 self.real_widget.setScaleStart(start) | |
79 scale_start = property(getScaleStart, setScaleStart) | |
80 | |
81 def getScaleEnd(self): | |
82 """getScaleEnd(self) -> double""" | |
83 return self.real_widget.getScaleEnd() | |
84 | |
85 def setScaleEnd(self, end): | |
86 """setScaleEnd(self, double scaleEnd)""" | |
87 if type(end) != float: | |
88 raise RuntimeError("Slider expects float for end scale") | |
89 self.real_widget.setScaleEnd(end) | |
90 scale_end = property(getScaleEnd, setScaleEnd) | |
91 | |
92 def getValue(self): | |
93 """getValue(self) -> double""" | |
94 return self.real_widget.getValue() | |
95 | |
96 def setValue(self, value): | |
97 """setValue(self, double value)""" | |
98 if type(value) != float: | |
99 raise RuntimeError("Slider only accepts float values") | |
100 self.real_widget.setValue(value) | |
101 | |
102 def setMarkerLength(self, length): | |
103 """setMarkerLength(self, int length)""" | |
104 if type(length) != int: | |
105 raise RuntimeError("Slider only accepts int for Marker lenght") | |
106 self.real_widget.setMarkerLength(length) | |
107 | |
108 def getMarkerLength(self): | |
109 """getMarkerLength(self) -> int""" | |
110 return self.real_widget.getMarkerLength() | |
111 | |
112 def setOrientation(self, orientation): | |
113 """setOrientation(self, Orientation orientation)""" | |
114 self.real_widget.setOrientation(orientation) | |
115 | |
116 def getOrientation(self): | |
117 """getOrientation(self) -> int""" | |
118 return self.real_widget.getOrientation() | |
119 orientation = property(getOrientation, setOrientation) | |
120 | |
121 def setStepLength(self, length): | |
122 """setStepLength(self, double length)""" | |
123 if type(length) != float: | |
124 raise RuntimeError("Slider only accepts floats for step length") | |
125 self.real_widget.setStepLength(length) | |
126 | |
127 def getStepLength(self): | |
128 """getStepLength(self) -> double""" | |
129 return self.real_widget.getStepLength() |