comparison engine/extensions/pychan/__init__.py @ 205:54bfd1015b35

* PyChan event handling rework (part I) ** Unified listeners ** ...hopefully more robust attach/detach code. * Added compat, layout and also the new autopsition feature. * Documentation * Minor style fixes in core.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 14 Mar 2009 12:13:29 +0000
parents 06dddc96ce54
children b0c4e6e41659
comparison
equal deleted inserted replaced
204:5816ab527da8 205:54bfd1015b35
8 8
9 Features 9 Features
10 -------- 10 --------
11 - Simpler Interface 11 - Simpler Interface
12 - Very Basic XML Format support 12 - Very Basic XML Format support
13 - Very Basic Layout Engine 13 - Basic Layout Engine
14 - Pseudo-Synchronous Dialogs. 14 - Pseudo-Synchronous Dialogs.
15 - Automagic background tiling (WIP) 15 - Automagic background tiling (WIP)
16 - Basic Styling support. 16 - Basic Styling support.
17 - Simple Font Handling 17 - Simple Font Handling
18 18
22 - Finalize Widget.execute 22 - Finalize Widget.execute
23 23
24 - Documentation ( Allways not enough :-( ) 24 - Documentation ( Allways not enough :-( )
25 - Handle Image Fonts 25 - Handle Image Fonts
26 - Move Font config files to XML, too ... 26 - Move Font config files to XML, too ...
27 - Add support for fixed size 'Spacers'
28 - Add messageBox(text)
29 27
30 - Implement real Menus 28 - Implement real Menus
31 - Implement StackWidget 29 - Implement StackWidget
32 - Then implement TabWidget 30 - Then implement TabWidget
33 31
35 - Table 33 - Table
36 34
37 BUGS 35 BUGS
38 ---- 36 ----
39 - Focus problems with Widget.execute. 37 - Focus problems with Widget.execute.
40 - Layout Bugs where max_size of a parent widget get's ignored.
41 - Font.glyph_spacing is rendered incorrectly. 38 - Font.glyph_spacing is rendered incorrectly.
42 - It just looks ugly. 39 - Is this a bug? At least inconvenient. MouseEntered events are not distributed for freshly shown widget.
40 - It just looks bad.
43 41
44 Problems 42 Problems
45 -------- 43 --------
46 - Reference counting problems again -sigh- 44 - Reference counting problems again -sigh-
47 ... and thus possible leaks. 45 ... and thus possible leaks.
152 'default' : { 150 'default' : {
153 'font' : 'console_small' 151 'font' : 'console_small'
154 } 152 }
155 } 153 }
156 154
155 A new style is added to pychan with L{internal.Manager.addStyle}.
156
157 The font is set via a string identifier pulled from a font definition 157 The font is set via a string identifier pulled from a font definition
158 in a PyChan configuration file. You have to load these by calling 158 in a PyChan configuration file. You have to load these by calling
159 L{loadFonts} in your startup code:: 159 L{loadFonts} in your startup code::
160 import pychan 160 import pychan
161 pychan.init( fifeEngine ) 161 pychan.init( fifeEngine )
223 'loadFonts', 223 'loadFonts',
224 'init', 224 'init',
225 'manager' 225 'manager'
226 ] 226 ]
227 227
228 import fife, pythonize
229
230 from widgets import * 228 from widgets import *
231 from exceptions import * 229 from exceptions import *
232 230
233 from fonts import loadFonts 231 from fonts import loadFonts
234 232
242 This has to be called before any other pychan methods can be used. 240 This has to be called before any other pychan methods can be used.
243 It sets up a manager object which is available under pychan.manager. 241 It sets up a manager object which is available under pychan.manager.
244 242
245 @param engine: The FIFE engine object. 243 @param engine: The FIFE engine object.
246 """ 244 """
247 from manager import Manager 245 from compat import _munge_engine_hook
246 from internal import Manager
248 global manager 247 global manager
249 manager = Manager(engine,debug) 248
249 manager = Manager(_munge_engine_hook(engine),debug)
250 250
251 # XML Loader 251 # XML Loader
252 252
253 from xml.sax import saxutils, handler 253 from xml.sax import saxutils, handler
254 from traceback import print_exc 254 from traceback import print_exc
324 self.root.addChild( obj ) 324 self.root.addChild( obj )
325 self.root = obj 325 self.root = obj
326 326
327 def _createSpacer(self,cls,name,attrs): 327 def _createSpacer(self,cls,name,attrs):
328 obj = cls(parent=self.root) 328 obj = cls(parent=self.root)
329 for k,v in attrs.items():
330 self._setAttr(obj,k,v)
331
329 if hasattr(self.root,'add'): 332 if hasattr(self.root,'add'):
330 self.root.addSpacer(obj) 333 self.root.addSpacer(obj)
331 else: 334 else:
332 raise GuiXMLError("A spacer needs to be added to a container widget!") 335 raise GuiXMLError("A spacer needs to be added to a container widget!")
333 self.root = obj 336 self.root = obj