]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/modules/html/htmlhelper.py
4 # A few helper functions for putting wxPython widgets in html pages
6 # Harm van der Heijden, 11 aug 1999.
12 # Function to parse a param string (of the form 'item=value item2="value etc"'
13 # and creates a dictionary
14 def _param2dict(param
):
15 i
= 0; j
= 0; s
= len(param
); d
= {}
16 d
['param_str'] = param
18 while i
<s
and param
[i
] == " " : i
= i
+1
21 while j
<s
and param
[j
] != "=": j
=j
+1
28 while j
<s
and param
[j
] != '"' : j
=j
+1
31 elif (param
[i
] != " "):
33 while j
<s
and param
[j
] != " " : j
=j
+1
38 d
[string
.lower(word
)] = val
41 # This function gets called by the <python> tag handler.
42 # Arguments are the parent (wxHtmlWindow) SWIG pointer (in python, a string)
43 # and a string containing the parameters.
44 # The return value must be the SWIG pointer of the created widget (the 'this'
45 # attribute in python). The widget must be derived from a wxWindow or one
47 def _WidgetStarter(parentptr
, param
):
48 # create a python instance of the parent
49 parent
= wx
.wxWindowPtr(parentptr
)
50 # try to find the widget class in the htmlwinc (=htmlwidget) module
51 dict = _param2dict(param
)
52 classname
= dict['class']
53 obj
= htmlc
.__dict
__[classname
]
54 # now create the class with arguments parent, dictionary
55 cls
= apply(obj
, (parent
, dict))
56 # return the class instance's pointer
59 htmlc
.WidgetStarter
= _WidgetStarter