Mercurial > fife-parpg
comparison demos/pychan_demo/styling.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 | 70697641fca3 |
comparison
equal
deleted
inserted
replaced
377:fe6fb0e0ed23 | 378:64738befdf3b |
---|---|
1 # -*- coding: utf-8 -*- | |
2 | |
3 from fife import fife | |
4 | |
5 from fife.extensions import pychan | |
6 | |
7 from pychan_test import PyChanExample | |
8 | |
9 STYLES= { | |
10 'new default': { | |
11 'default' : { | |
12 'border_size': 2, | |
13 'margins': (0,0), | |
14 'base_color' : fife.Color(128,128,128), | |
15 'foreground_color' : fife.Color(255,255,255), | |
16 'background_color' : fife.Color(55,55,55), | |
17 'font' : 'samanata_small' | |
18 }, | |
19 'Button' : { | |
20 'border_size': 2, | |
21 'margins' : (20,5), | |
22 'min_size' : (100,20), | |
23 'font' : 'samanata_small' | |
24 }, | |
25 'CheckBox' : { | |
26 'border_size': 0, | |
27 'background_color' : fife.Color(0,0,0,0), | |
28 }, | |
29 'RadioButton' : { | |
30 'border_size': 0, | |
31 'background_color' : fife.Color(0,0,0,0), | |
32 }, | |
33 'Label' : { | |
34 'border_size': 0, | |
35 'font' : 'samanata_small' | |
36 }, | |
37 'ClickLabel' : { | |
38 'border_size': 0, | |
39 'font' : 'samanata_small' | |
40 }, | |
41 'ListBox' : { | |
42 'border_size': 0, | |
43 'font' : 'samanata_small' | |
44 }, | |
45 'Window' : { | |
46 'border_size': 1, | |
47 'margins': (10,10), | |
48 'opaque' : 0, | |
49 'titlebar_height' : 30, | |
50 'background_image' : 'gui/backgrounds/background.png', | |
51 'font' : 'samanata_large' | |
52 }, | |
53 'TextBox' : { | |
54 'font' : 'samanata_small' | |
55 }, | |
56 ('Container','HBox','VBox') : { | |
57 'border_size': 0, | |
58 'background_image' : 'gui/backgrounds/background.png', | |
59 'opaque' : False | |
60 } | |
61 }, | |
62 'greenzone' : { | |
63 'default' : { | |
64 'base_color': fife.Color(80,200,80) , | |
65 'background_color': fife.Color(200,250,200), | |
66 }, | |
67 'Window' : { | |
68 'titlebar_height' : 30, | |
69 }, | |
70 'ListBox' : { | |
71 'font' : 'samanata_large' | |
72 } | |
73 } | |
74 } | |
75 | |
76 class StylingExample(PyChanExample): | |
77 def __init__(self): | |
78 super(StylingExample,self).__init__('gui/styling.xml') | |
79 | |
80 self.styles = ['default'] + STYLES.keys() | |
81 for name,style in STYLES.items(): | |
82 pychan.manager.addStyle(name,style) | |
83 | |
84 pychan.loadFonts("fonts/samanata.fontdef") | |
85 | |
86 def start(self): | |
87 self.styledCredits = pychan.loadXML('gui/all_widgets.xml') | |
88 self.styledCredits.distributeInitialData({ | |
89 'demoList' : map(lambda x:unicode(x,'utf8'),dir(pychan)), | |
90 'demoText' : unicode(pychan.__doc__,'utf8') | |
91 }) | |
92 | |
93 self.widget = pychan.loadXML(self.xmlFile) | |
94 self.widget.mapEvents({ | |
95 'testStyle' : self.testStyle, | |
96 'closeButton':self.stop, | |
97 }) | |
98 self.widget.distributeInitialData({ | |
99 'styleList' : self.styles | |
100 }) | |
101 self.widget.position_technique = 'right-20:center' | |
102 self.styledCredits.position_technique = 'left+20:center' | |
103 self.widget.show() | |
104 self.styledCredits.show() | |
105 | |
106 def stop(self): | |
107 super(StylingExample,self).stop() | |
108 if self.styledCredits: | |
109 self.styledCredits.hide() | |
110 | |
111 def testStyle(self): | |
112 style = self.styles[self.widget.collectData('styleList')] | |
113 if self.styledCredits: | |
114 self.styledCredits.hide() | |
115 self.styledCredits.stylize(style) | |
116 self.styledCredits.show() |