Mercurial > fife-parpg
comparison clients/pychan_demo/styling.py @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 97d6946bd917 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 #!/usr/bin/env python | |
2 # coding: utf-8 | |
3 | |
4 import sys, os, re | |
5 | |
6 def _jp(path): | |
7 return os.path.sep.join(path.split('/')) | |
8 | |
9 _paths = ('../../engine/swigwrappers/python', '../../engine/extensions') | |
10 for p in _paths: | |
11 if p not in sys.path: | |
12 sys.path.append(_jp(p)) | |
13 | |
14 import fife | |
15 import fifelog | |
16 import settings | |
17 | |
18 import pychan | |
19 | |
20 from pychan_test import PyChanExample | |
21 | |
22 STYLES= { | |
23 'new default': { | |
24 'default' : { | |
25 'border_size': 2, | |
26 'margins': (0,0), | |
27 'base_color' : fife.Color(128,128,128), | |
28 'foreground_color' : fife.Color(255,255,255), | |
29 'background_color' : fife.Color(55,55,55), | |
30 'font' : 'samanata_small' | |
31 }, | |
32 'Button' : { | |
33 'border_size': 2, | |
34 'margins' : (20,5), | |
35 'min_size' : (100,20), | |
36 'font' : 'samanata_small' | |
37 }, | |
38 'CheckBox' : { | |
39 'border_size': 0, | |
40 'background_color' : fife.Color(0,0,0,0), | |
41 }, | |
42 'RadioButton' : { | |
43 'border_size': 0, | |
44 'background_color' : fife.Color(0,0,0,0), | |
45 }, | |
46 'Label' : { | |
47 'border_size': 0, | |
48 'font' : 'samanata_small' | |
49 }, | |
50 'ClickLabel' : { | |
51 'border_size': 0, | |
52 'font' : 'samanata_small' | |
53 }, | |
54 'ListBox' : { | |
55 'border_size': 0, | |
56 'font' : 'samanata_small' | |
57 }, | |
58 'Window' : { | |
59 'border_size': 1, | |
60 'margins': (10,10), | |
61 'opaque' : 0, | |
62 'titlebar_height' : 30, | |
63 'background_image' : 'content/gui/background.png', | |
64 'font' : 'samanata_large' | |
65 }, | |
66 'TextBox' : { | |
67 'font' : 'samanata_small' | |
68 }, | |
69 ('Container','HBox','VBox') : { | |
70 'border_size': 0, | |
71 'background_image' : 'content/gui/background.png', | |
72 'opaque' : False | |
73 } | |
74 }, | |
75 'greenzone' : { | |
76 'default' : { | |
77 'base_color': fife.Color(80,200,80) , | |
78 'background_color': fife.Color(200,250,200), | |
79 }, | |
80 'ListBox' : { | |
81 'font' : 'samanata_large' | |
82 } | |
83 } | |
84 } | |
85 | |
86 class StylingExample(PyChanExample): | |
87 def __init__(self): | |
88 super(StylingExample,self).__init__('content/gui/styling.xml') | |
89 | |
90 self.styles = ['default'] + STYLES.keys() | |
91 for name,style in STYLES.items(): | |
92 pychan.manager.addStyle(name,style) | |
93 | |
94 pychan.loadFonts("content/fonts/samanata.fontdef") | |
95 | |
96 def start(self): | |
97 self.styledCredits = None | |
98 self.widget = pychan.loadXML(self.xmlFile) | |
99 self.widget.mapEvents({ | |
100 'testStyle' : self.testStyle, | |
101 'closeButton':self.stop, | |
102 }) | |
103 self.widget.distributeInitialData({ | |
104 'styleList' : self.styles | |
105 }) | |
106 self.widget.show() | |
107 | |
108 def stop(self): | |
109 super(StylingExample,self).stop() | |
110 if self.styledCredits: | |
111 self.styledCredits.hide() | |
112 | |
113 def testStyle(self): | |
114 style = self.styles[self.widget.collectData('styleList')] | |
115 if self.styledCredits: | |
116 self.styledCredits.hide() | |
117 self.styledCredits = pychan.loadXML('content/gui/all_widgets.xml') | |
118 self.styledCredits.distributeInitialData({ | |
119 'demoList' : dir(pychan), | |
120 'demoText' : pychan.__doc__ | |
121 }) | |
122 self.styledCredits.stylize(style) | |
123 self.styledCredits.mapEvents({'okButton':self.styledCredits.hide}) | |
124 self.styledCredits.show() |