| Home | Trees | Indices | Help |
|
|---|
|
|
1 # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net>
2 #
3 # Pyjamas Widget Factory. register widgets with this module,
4 # for dynamic use in applications. please observe namespaces.
5 #
6 # * pyjamas.ui namespace is used for widgets in library/pyjamas/ui
7
8 #from __pyjamas__ import doc
9 from pyjamas import DOM
10
11 factory = {}
12
14 global factory
15 if modname is None:
16 modname = '.'.join(['pyjamas.ui', klsname])
17 name = '.'.join([modname, klsname])
18 factory[name] = kls
19
21 return factory[name]
22
24 fc = DOM.getAttribute(element, 'id')
25 lbr = fc.find("(")
26 klsname = fc[:lbr]
27 txtargs = fc[lbr+1:-1]
28 args = []
29 kwargs = {}
30 for arg in txtargs.split(','):
31 findeq = arg.find('=')
32 if findeq == -1:
33 args.append(arg)
34 else:
35 k = arg[:findeq]
36 v = arg[findeq+1:]
37 if ((v[0] == "'" and v[-1] == "'") or
38 (v[0] == '"' and v[-1] == '"')):
39 # string - strip quotes
40 v = v[1:-1]
41 else:
42 # assume it's an int
43 v = int(v)
44 kwargs[k] = v
45
46 kwargs['Element'] = element
47 return lookupClass(klsname)(*args, **kwargs)
48
51 #try:
52 # ns = doc().namespaces.item("pyjs")
53 #except:
54 # doc().namespaces.add("pyjsinit", "urn:schemas-pyjs-org:pyjs")
55 #doc().createStyleSheet().cssText = "v\\:*{behavior:url(#default#VML);}"
56
| Home | Trees | Indices | Help |
|
|---|
| http://epydoc.sourceforge.net |