X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fb757066dfea26412c518153f7c4af05a8a43dc9..a7a014180017908d32f0af32ebfa140fdc82b390:/wxPython/wx/lib/wxpTag.py diff --git a/wxPython/wx/lib/wxpTag.py b/wxPython/wx/lib/wxpTag.py index 8dbb7109d4..5de374e990 100644 --- a/wxPython/wx/lib/wxpTag.py +++ b/wxPython/wx/lib/wxpTag.py @@ -10,6 +10,10 @@ # Copyright: (c) 1999 by Total Control Software # Licence: wxWindows license #---------------------------------------------------------------------- +# 12/13/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for V2.5 compatability +# ''' wxPython.lib.wxpTag @@ -31,11 +35,11 @@ Tags of the following form are recognised: where modulename is the name of a module (possibly in package notation) to import and classname is the name of a class in that module to create an instance of. If the module tag-attribute is not -given or is an empty string, then wxPython.wx is used. The width and -height attributes are expected to be integers and will be passed to -the __init__ method of the class as a wxSize object named size. -However, if the width attribute ends with the percent (%) symbol then -the value will be used as a percentage of the available width and the +given or is an empty string, then wx is used. The width and height +attributes are expected to be integers and will be passed to the +__init__ method of the class as a wxSize object named size. However, +if the width attribute ends with the percent (%) symbol then the value +will be used as a percentage of the available width and the wxHtmlWindow will manage the size. The name-value pairs in all the nested PARAM tags are packaged up as @@ -69,9 +73,9 @@ be converted from strings to alternate datatypes. They are: An example: - + - + Both the begining and ending WXP tags are required. @@ -85,11 +89,11 @@ server as is done with java applets. ''' #---------------------------------------------------------------------- -from wxPython.wx import * -from wxPython.html import * -import wxPython.wx +import types + +import wx +import wx.html -import types #---------------------------------------------------------------------- @@ -98,19 +102,16 @@ PARAMTAG = 'PARAM' #---------------------------------------------------------------------- -class wxpTagHandler(wxHtmlWinTagHandler): +class wxpTagHandler(wx.html.HtmlWinTagHandler): def __init__(self): - print 'wxpTagHandler' - wxHtmlWinTagHandler.__init__(self) + wx.html.HtmlWinTagHandler.__init__(self) self.ctx = None def GetSupportedTags(self): - print 'wxpTagHandler.GetSupportedTags' return WXPTAG+','+PARAMTAG def HandleTag(self, tag): - print 'wxpTagHandler.HandleTag' name = tag.GetName() if name == WXPTAG: return self.HandleWxpTag(tag) @@ -131,7 +132,7 @@ class wxpTagHandler(wxHtmlWinTagHandler): if modName: self.ctx.classMod = _my_import(modName) else: - self.ctx.classMod = wxPython.wx + self.ctx.classMod = wx # find and verify the class if not tag.HasParam('CLASS'): @@ -154,7 +155,7 @@ class wxpTagHandler(wxHtmlWinTagHandler): width = int(width) if tag.HasParam('HEIGHT'): height = int(tag.GetParam('HEIGHT')) - self.ctx.kwargs['size'] = wxSize(width, height) + self.ctx.kwargs['size'] = wx.Size(width, height) # parse up to the closing tag, and gather any nested Param tags. self.ParseInner(tag) @@ -168,7 +169,8 @@ class wxpTagHandler(wxHtmlWinTagHandler): obj.Show(True) # add it to the HtmlWindow - self.GetParser().GetContainer().InsertCell(wxHtmlWidgetCell(obj, self.ctx.floatWidth)) + self.GetParser().GetContainer().InsertCell( + wx.html.HtmlWidgetCell(obj, self.ctx.floatWidth)) self.ctx = None return True @@ -194,24 +196,25 @@ class wxpTagHandler(wxHtmlWinTagHandler): # check for something that should be evaluated - elif value[0] in '[{(' or value[:2] == 'wx': + elif value and value[0] in '[{(' or value[:2] == 'wx': saveVal = value try: value = eval(value, self.ctx.classMod.__dict__) except: value = saveVal - # convert to wxColour - elif value[0] == '#': + # convert to wx.Colour + elif value and value[0] == '#': try: red = int('0x'+value[1:3], 16) green = int('0x'+value[3:5], 16) blue = int('0x'+value[5:], 16) - value = wxColor(red, green, blue) + value = wx.Color(red, green, blue) except: pass - self.ctx.kwargs[str(name)] = value + if self.ctx: + self.ctx.kwargs[str(name)] = value return False @@ -270,4 +273,4 @@ def _param2dict(param): -wxHtmlWinParser_AddTagHandler(wxpTagHandler) +wx.html.HtmlWinParser_AddTagHandler(wxpTagHandler)