Mercurial > fife-parpg
comparison clients/pychan_demo/styling.py @ 255:51cc05d862f2
Merged editor_rewrite branch to trunk.
This contains changes that may break compatibility against existing clients.
For a list of changes that may affect your client, see: http://wiki.fifengine.de/Changes_to_pychan_and_FIFE_in_editor_rewrite_branch
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 08 Jun 2009 16:00:02 +0000 |
parents | f98443afed5b |
children | dfd48d49c044 |
comparison
equal
deleted
inserted
replaced
254:10b5f7f36dd4 | 255:51cc05d862f2 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # coding: utf-8 | 2 # -*- coding: utf-8 -*- |
3 | 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 | 4 |
14 import fife | 5 import fife |
15 import fifelog | |
16 import settings | |
17 | 6 |
18 import pychan | 7 import pychan |
19 | 8 |
20 from pychan_test import PyChanExample | 9 from pychan_test import PyChanExample |
21 | 10 |
75 'greenzone' : { | 64 'greenzone' : { |
76 'default' : { | 65 'default' : { |
77 'base_color': fife.Color(80,200,80) , | 66 'base_color': fife.Color(80,200,80) , |
78 'background_color': fife.Color(200,250,200), | 67 'background_color': fife.Color(200,250,200), |
79 }, | 68 }, |
69 'Window' : { | |
70 'titlebar_height' : 30, | |
71 }, | |
80 'ListBox' : { | 72 'ListBox' : { |
81 'font' : 'samanata_large' | 73 'font' : 'samanata_large' |
82 } | 74 } |
83 } | 75 } |
84 } | 76 } |
92 pychan.manager.addStyle(name,style) | 84 pychan.manager.addStyle(name,style) |
93 | 85 |
94 pychan.loadFonts("fonts/samanata.fontdef") | 86 pychan.loadFonts("fonts/samanata.fontdef") |
95 | 87 |
96 def start(self): | 88 def start(self): |
97 self.styledCredits = None | 89 self.styledCredits = pychan.loadXML('gui/all_widgets.xml') |
90 self.styledCredits.distributeInitialData({ | |
91 'demoList' : map(lambda x:unicode(x,'utf8'),dir(pychan)), | |
92 'demoText' : unicode(pychan.__doc__,'utf8') | |
93 }) | |
94 | |
98 self.widget = pychan.loadXML(self.xmlFile) | 95 self.widget = pychan.loadXML(self.xmlFile) |
99 self.widget.mapEvents({ | 96 self.widget.mapEvents({ |
100 'testStyle' : self.testStyle, | 97 'testStyle' : self.testStyle, |
101 'closeButton':self.stop, | 98 'closeButton':self.stop, |
102 }) | 99 }) |
103 self.widget.distributeInitialData({ | 100 self.widget.distributeInitialData({ |
104 'styleList' : self.styles | 101 'styleList' : self.styles |
105 }) | 102 }) |
103 self.widget.position_technique = 'right-20:center' | |
104 self.styledCredits.position_technique = 'left+20:center' | |
106 self.widget.show() | 105 self.widget.show() |
106 self.styledCredits.show() | |
107 | 107 |
108 def stop(self): | 108 def stop(self): |
109 super(StylingExample,self).stop() | 109 super(StylingExample,self).stop() |
110 if self.styledCredits: | 110 if self.styledCredits: |
111 self.styledCredits.hide() | 111 self.styledCredits.hide() |
112 | 112 |
113 def testStyle(self): | 113 def testStyle(self): |
114 style = self.styles[self.widget.collectData('styleList')] | 114 style = self.styles[self.widget.collectData('styleList')] |
115 if self.styledCredits: | 115 if self.styledCredits: |
116 self.styledCredits.hide() | 116 self.styledCredits.hide() |
117 self.styledCredits = pychan.loadXML('gui/all_widgets.xml') | |
118 self.styledCredits.distributeInitialData({ | |
119 'demoList' : dir(pychan), | |
120 'demoText' : pychan.__doc__ | |
121 }) | |
122 self.styledCredits.stylize(style) | 117 self.styledCredits.stylize(style) |
123 self.styledCredits.mapEvents({'okButton':self.styledCredits.hide}) | |
124 self.styledCredits.show() | 118 self.styledCredits.show() |