X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8a693e6e0460b6b3c32e4b6f114a3ab7b7cd24ea..f6bcfd974ef26faf6f91a62cac09827e09463fd1:/utils/wxPython/lib/wxpTag.py
diff --git a/utils/wxPython/lib/wxpTag.py b/utils/wxPython/lib/wxpTag.py
deleted file mode 100644
index 4cc06d6eff..0000000000
--- a/utils/wxPython/lib/wxpTag.py
+++ /dev/null
@@ -1,281 +0,0 @@
-#----------------------------------------------------------------------
-# Name: wxPython.lib.wxpTag
-# Purpose: A wxHtmlTagHandler that knows how to build and place
-# wxPython widgets onto web pages.
-#
-# Author: Robin Dunn
-#
-# Created: 13-Sept-1999
-# RCS-ID: $Id$
-# Copyright: (c) 1999 by Total Control Software
-# Licence: wxWindows license
-#----------------------------------------------------------------------
-
-'''
-wxPython.lib.wxpTag
-
-This module contains a wxHtmlTagHandler that knows how to build
-and place wxPython widgets onto wxHtmlWindow web pages.
-
-You don\'t need to use anything in this module directly, just
-importing it will create the tag handler and add it to any
-wxHtmlWinParsers created from that time forth.
-
-Tags of the following form are recognised:
-
-
-
-
-
-
-
-Both the begining and ending WXP tags are required.
-
-In the future support will be added for another tag that can be
-embedded between the two begining and ending WXP tags and will
-facilitate calling methods of the widget to help initialize it.
-Additionally, support may be added to fetch the module from a web
-server as is done with java applets.
-
-'''
-#----------------------------------------------------------------------
-
-from wxPython.wx import *
-from wxPython.html import *
-import wxPython.wx
-
-import string
-import types
-
-#----------------------------------------------------------------------
-
-WXPTAG = 'WXP'
-PARAMTAG = 'PARAM'
-
-#----------------------------------------------------------------------
-
-class wxpTagHandler(wxHtmlWinTagHandler):
- def __init__(self):
- wxHtmlWinTagHandler.__init__(self)
- self.ctx = None
-
- def GetSupportedTags(self):
- return WXPTAG+','+PARAMTAG
-
-
- def HandleTag(self, tag):
- name = tag.GetName()
- if name == WXPTAG:
- return self.HandleWxpTag(tag)
- elif name == PARAMTAG:
- return self.HandleParamTag(tag)
- else:
- raise ValueError, 'unknown tag: ' + name
-
-
- def HandleWxpTag(self, tag):
- if tag.IsEnding():
- return false
-
- # create a new context object
- self.ctx = _Context()
-
- # find and import the module
- modName = ''
- if tag.HasParam('MODULE'):
- modName = tag.GetParam('MODULE')
- if modName:
- self.ctx.classMod = _my_import(modName)
- else:
- self.ctx.classMod = wxPython.wx
-
- # find and verify the class
- if not tag.HasParam('CLASS'):
- raise AttributeError, "WXP tag requires a CLASS attribute"
-
- className = tag.GetParam('CLASS')
- self.ctx.classObj = getattr(self.ctx.classMod, className)
- if type(self.ctx.classObj) != types.ClassType:
- raise TypeError, "WXP tag attribute CLASS must name a class"
-
-
-
- # now look for width and height
- width = -1
- height = -1
- if tag.HasParam('WIDTH'):
- width = tag.GetParam('WIDTH')
- if width[-1] == '%':
- self.ctx.floatWidth = string.atoi(width[:-1], 0)
- width = self.ctx.floatWidth
- else:
- width = string.atoi(width)
- if tag.HasParam('HEIGHT'):
- height = string.atoi(tag.GetParam('HEIGHT'))
- self.ctx.kwargs['size'] = wxSize(width, height)
-
-
- self.ParseInner(tag)
-
- # create the object
- parent = self.GetParser().GetWindow()
- if parent:
- obj = apply(self.ctx.classObj,
- (parent,),
- self.ctx.kwargs)
- obj.Show(true)
-
- # add it to the HtmlWindow
- self.GetParser().GetContainer().InsertCell(wxHtmlWidgetCell(obj, self.ctx.floatWidth))
- self.ctx = None
-
- return true
-
-
-
-
- def HandleParamTag(self, tag):
- if tag.IsEnding():
- return false
-
- if not tag.HasParam('NAME'):
- return false
-
- name = tag.GetParam('NAME')
- value = ""
- if tag.HasParam('VALUE'):
- value = tag.GetParam('VALUE')
-
- # check for a param named 'id'
- if name == 'id':
- theID = -1
- try:
- theID = string.atoi(value)
- except ValueError:
- theID = getattr(self.ctx.classMod, value)
- value = theID
-
-
- # check for something that should be evaluated
- elif value[0] in '[{(' or value[:2] == 'wx':
- saveVal = value
- try:
- value = eval(value, self.ctx.classMod.__dict__)
- except:
- value = saveValue
-
- # convert to wxColour
- elif value[0] == '#':
- try:
- red = string.atoi('0x'+value[1:3], 16)
- green = string.atoi('0x'+value[3:5], 16)
- blue = string.atoi('0x'+value[5:], 16)
- value = wxColor(red, green, blue)
- except:
- pass
-
- self.ctx.kwargs[name] = value
- return false
-
-
-#----------------------------------------------------------------------
-# just a place to hold some values
-class _Context:
- def __init__(self):
- self.kwargs = {}
- self.width = -1
- self.height = -1
- self.classMod = None
- self.classObj = None
- self.floatWidth = 0
-
-
-#----------------------------------------------------------------------
-# Function to assist with importing packages
-def _my_import(name):
- mod = __import__(name)
- components = string.split(name, '.')
- for comp in components[1:]:
- mod = getattr(mod, comp)
- return mod
-
-
-#----------------------------------------------------------------------
-# 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 = {}
- 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