Package wx :: Package lib :: Module wxpTag
[frames | no frames]

Module wx.lib.wxpTag

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:

<WXP class="classname" [module="modulename"] [width="num"] [height="num"]>
    <PARAM name="parameterName" value="parameterValue>
    ...
</WXP>

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 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 strings into a python dictionary and passed to the __init__ method of the class as keyword arguments. This means that they are all accessible from the __init__ method as regular parameters, or you use the special Python **kw syntax in your __init__ method to get the dictionary directly.

Some parameter values are special and if they are present then they will be converted from strings to alternate datatypes. They are:

id If the value of id can be converted to an integer, it will
be. Otherwise it is assumed to be the name of an integer variable in the module.
colours Any value of the form "#123ABC" will automatically be
converted to a wxColour object.
Py Types Any value begining with "(", "[" or "{" are expected to
be a Python tuple, list, or dictionary and eval() will be used to convert them to that type. If the eval() fails then the original string value will be preserved.
wx Types Any value begining with "wx" is expected to be an attempt
to create a wxPython object, such as a wxSize, etc. The eval() will be used to try and construct the object and if it fails then the original string value will be used instead.

An example:

<wxp module="wx" class="Button">
    <param name="label" value="Click here">
    <param name="id" value="ID_OK">
</wxp>

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.


Classes
wxpTagHandler  

Generated by Epydoc 2.1.20050511.rpd on Mon Feb 16 12:52:07 2009 http://epydoc.sf.net