Mercurial > fife-parpg
annotate demos/pychan_demo/colortester.py @ 657:d30ae69a2a20
Added the README for the upcoming win32 devkit update. The devkit.iss installer scrips relies on the existence of the file anyway, so it sounds like a good idea to have it in SVN as well. Makes future updates to the file easier as well :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 30 Oct 2010 18:23:45 +0000 |
parents | 8c9cdcc9bc4f |
children |
rev | line source |
---|---|
438
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # Copyright (C) 2005-2010 by the FIFE team |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # http://www.fifengine.de |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 """ pychan demo app for testing rgba colors on widgets """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 |
613
8c9cdcc9bc4f
Renaming pychan_test.py to pychan_demo.py to make it a bit more obvious which file to execute.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
590
diff
changeset
|
26 from pychan_demo import PyChanExample |
438
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 from fife.extensions import pychan |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 class ColorExample(PyChanExample): |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 """ a small app (^^) to show how guichan uses colors on various widgets """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 def __init__(self): |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 super(ColorExample,self).__init__('gui/colortester.xml') |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 def start(self): |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 load XML file and setup callbacks |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 self.widget = pychan.loadXML(self.xmlFile) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 self.widget.mapEvents({ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 'base_rslider': self.update_basecolor, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 'base_gslider': self.update_basecolor, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 'base_bslider': self.update_basecolor, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 'base_aslider': self.update_basecolor, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 'background_rslider': self.update_background_color, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 'background_gslider': self.update_background_color, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 'background_bslider': self.update_background_color, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 'background_aslider': self.update_background_color, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 'closeButton':self.stop, |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 }) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 # alpha value needs to be set, otherwise you don't see colors ;-) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 self.widget.findChild(name="base_aslider").setValue(float(255)) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 self.widget.findChild(name="background_aslider").setValue(float(255)) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 # init stuff |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 self.update_basecolor() |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 self.update_background_color() |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 self.widget.show() |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 def update_basecolor(self): |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 Update rgba base colors of all examples and show the values |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 r = int(self.widget.findChild(name="base_rslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 g = int(self.widget.findChild(name="base_gslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 b = int(self.widget.findChild(name="base_bslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 a = int(self.widget.findChild(name="base_aslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 # update slider labels |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 self.widget.findChild(name="base_rvalue").text = unicode(str(r), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 self.widget.findChild(name="base_gvalue").text = unicode(str(g), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 self.widget.findChild(name="base_bvalue").text = unicode(str(b), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 self.widget.findChild(name="base_avalue").text = unicode(str(a), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 rgba = (r, g, b, a) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 # background_color, foreground_color, base_color, selection_color (listbox) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 self.widget.findChild(name="example1").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 self.widget.findChild(name="example2").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 self.widget.findChild(name="example3").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
82 self.widget.findChild(name="example4").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
83 self.widget.findChild(name="example5").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
84 self.widget.findChild(name="example6").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
85 self.widget.findChild(name="example7").base_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
86 self.widget.findChild(name="example8").base_color = rgba |
590
59c92d10d7bc
- added label to colortester
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
438
diff
changeset
|
87 self.widget.findChild(name="example9").base_color = rgba |
438
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
88 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
89 def update_background_color(self): |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 Update rgba background colors of all examples and show the values |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 """ |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
93 r = int(self.widget.findChild(name="background_rslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 g = int(self.widget.findChild(name="background_gslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 b = int(self.widget.findChild(name="background_bslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 a = int(self.widget.findChild(name="background_aslider").getValue()) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
97 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
98 # update slider labels |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 self.widget.findChild(name="background_rvalue").text = unicode(str(r), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
100 self.widget.findChild(name="background_gvalue").text = unicode(str(g), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
101 self.widget.findChild(name="background_bvalue").text = unicode(str(b), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 self.widget.findChild(name="background_avalue").text = unicode(str(a), "utf-8") |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
104 rgba = (r, g, b, a) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
105 |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 # background_color, foreground_color, background_color, selection_color (listbox) |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 self.widget.findChild(name="example1").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 self.widget.findChild(name="example2").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 self.widget.findChild(name="example3").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 self.widget.findChild(name="example4").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 self.widget.findChild(name="example5").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 self.widget.findChild(name="example6").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 self.widget.findChild(name="example7").background_color = rgba |
db994c01cc9a
- added color tester app to pychan demo
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 self.widget.findChild(name="example8").background_color = rgba |
590
59c92d10d7bc
- added label to colortester
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
438
diff
changeset
|
115 self.widget.findChild(name="example9").background_color = rgba |