#
# htmlhelper.py
#
# A few helper functions for putting wxPython widgets in html pages
#
# Harm van der Heijden, 11 aug 1999.
import wx
import string
import htmlc
# Function to parse a param string (of the form 'item=value item2="value etc"'
# and creates a dictionary
def _param2dict(param):
i = 0; j = 0; s = len(param); d = {}
d['param_str'] = param
while 1:
while i=s: break
j = i
while j=s:
break
word = param[i:j]
i=j+1
if (param[i] == '"'):
j=i+1
while j tag handler.
# Arguments are the parent (wxHtmlWindow) SWIG pointer (in python, a string)
# and a string containing the parameters.
# The return value must be the SWIG pointer of the created widget (the 'this'
# attribute in python). The widget must be derived from a wxWindow or one
# of its descendants.
def _WidgetStarter(parentptr, param):
# create a python instance of the parent
parent = wx.wxWindowPtr(parentptr)
# try to find the widget class in the htmlwinc (=htmlwidget) module
dict = _param2dict(param)
classname = dict['class']
obj = htmlc.__dict__[classname]
# now create the class with arguments parent, dictionary
cls = apply(obj, (parent, dict))
# return the class instance's pointer
return cls.this
htmlc.WidgetStarter = _WidgetStarter