.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2017 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.html.HtmlTag:
==========================================================================================================================================
|phoenix_title| **wx.html.HtmlTag**
==========================================================================================================================================
This class represents a single HTML tag.
It is used by :ref:`tag handlers `.
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html
Inheritance diagram for class
HtmlTag:
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.html.HtmlTag.GetAllParams` Returns a string containing all parameters.
:meth:`~wx.html.HtmlTag.GetBeginPos` Returns beginning position of the text `between` this tag and paired ending tag.
:meth:`~wx.html.HtmlTag.GetEndPos1` Returns ending position of the text `between` this tag and paired ending tag.
:meth:`~wx.html.HtmlTag.GetEndPos2` Returns ending position 2 of the text `between` this tag and paired ending tag.
:meth:`~wx.html.HtmlTag.GetName` Returns tag's name.
:meth:`~wx.html.HtmlTag.GetParam` Returns the value of the parameter.
:meth:`~wx.html.HtmlTag.GetParamAsColour` Interprets tag parameter `par` as colour specification and saves its value into :ref:`wx.Colour` variable pointed by `clr`.
:meth:`~wx.html.HtmlTag.GetParamAsInt` Interprets tag parameter `par` as an integer and saves its value into int variable pointed by `value`.
:meth:`~wx.html.HtmlTag.GetParamAsString` Get the value of the parameter.
:meth:`~wx.html.HtmlTag.HasEnding` Returns ``True`` if this tag is paired with ending tag, ``False`` otherwise.
:meth:`~wx.html.HtmlTag.HasParam` Returns ``True`` if the tag has a parameter of the given name.
:meth:`~wx.html.HtmlTag.ParseAsColour` Parses the given string as an HTML colour.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.html.HtmlTag.AllParams` See :meth:`~wx.html.HtmlTag.GetAllParams`
:attr:`~wx.html.HtmlTag.BeginPos` See :meth:`~wx.html.HtmlTag.GetBeginPos`
:attr:`~wx.html.HtmlTag.EndPos1` See :meth:`~wx.html.HtmlTag.GetEndPos1`
:attr:`~wx.html.HtmlTag.EndPos2` See :meth:`~wx.html.HtmlTag.GetEndPos2`
:attr:`~wx.html.HtmlTag.Name` See :meth:`~wx.html.HtmlTag.GetName`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.html.HtmlTag(object)
This class represents a single HTML tag.
.. method:: GetAllParams(self)
Returns a string containing all parameters.
Example: tag contains . Call to tag.GetAllParams() would return ``'SIZE=+2`` COLOR="#000000"'.
:rtype: `string`
.. method:: GetBeginPos(self)
Returns beginning position of the text `between` this tag and paired ending tag.
See explanation (returned position is marked with '|'):
.. code-block:: text
bla bla bla bla bla internal text bla bla
|
:rtype: `int`
.. todo:: provide deprecation description
.. method:: GetEndPos1(self)
Returns ending position of the text `between` this tag and paired ending tag.
See explanation (returned position is marked with '|'):
.. code-block:: text
bla bla bla bla bla internal text bla bla
|
:rtype: `int`
.. todo:: provide deprecation description
.. method:: GetEndPos2(self)
Returns ending position 2 of the text `between` this tag and paired ending tag.
See explanation (returned position is marked with '|'):
.. code-block:: text
bla bla bla bla bla internal text bla bla
|
:rtype: `int`
.. todo:: provide deprecation description
.. method:: GetName(self)
Returns tag's name.
The name is always in uppercase and it doesn't contain " or '/' characters. (So the name of tag is "FONT" and name of is "``TABLE``").
:rtype: `string`
.. method:: GetParam(self, par, with_quotes=False)
Returns the value of the parameter.
You should check whether the parameter exists or not (use :meth:`wx.html.HtmlTag.HasParam` ) first or use :meth:`GetParamAsString` if you need to distinguish between non-specified and empty parameter values.
:param `par`: The parameter's name.
:type `par`: string
:param `with_quotes`: ``True`` if you want to get quotes as well. See example.
:type `with_quotes`: bool
:rtype: `string`
::
# ... Some code here...
# you have wx.HtmlTag variable tag which is equal to the
# HTML tag
dummy = tag.GetParam("SIZE")
# dummy == "+2"
dummy = tag.GetParam("COLOR")
# dummy == "#0000FF"
dummy = tag.GetParam("COLOR", true)
# dummy == "\"#0000FF\"" -- see the difference!!
.. method:: GetParamAsColour(self, par)
Interprets tag parameter `par` as colour specification and saves its value into :ref:`wx.Colour` variable pointed by `clr`.
Returns ``True`` on success and ``False`` if `par` is not colour specification or if the tag has no such parameter.
:param `par`:
:type `par`: string
:rtype: `tuple`
:returns:
( `bool`, `clr` )
.. seealso:: :meth:`ParseAsColour`
.. method:: GetParamAsInt(self, par)
Interprets tag parameter `par` as an integer and saves its value into int variable pointed by `value`.
Returns ``True`` on success and ``False`` if `par` is not an integer or if the tag has no such parameter.
:param `par`:
:type `par`: string
:rtype: `tuple`
:returns:
( `bool`, `value` )
.. method:: GetParamAsString(self, par, value)
Get the value of the parameter.
If the tag doesn't have such parameter at all, simply returns ``False``. Otherwise, fills `value` with the parameter value and returns ``True``.
:param `par`: The parameter's name.
:type `par`: string
:param `value`: Pointer to the string to be filled with the parameter value, must be not ``None``.
:type `value`: string
:rtype: `bool`
.. versionadded:: 3.0
.. method:: HasEnding(self)
Returns ``True`` if this tag is paired with ending tag, ``False`` otherwise.
See the example of HTML document:
.. code-block:: html
Hello
How are you?
This is centered...
Oops
Oooops!
In this example tags HTML and ``BODY`` have ending tags, first P and ``BR`` doesn't have ending tag while the second P has. The third P tag (which is ending itself) of course doesn't have ending tag.
:rtype: `bool`
.. method:: HasParam(self, par)
Returns ``True`` if the tag has a parameter of the given name.
Example: has two parameters named "SIZE" and "COLOR".
:param `par`: the parameter you're looking for.
:type `par`: string
:rtype: `bool`
.. staticmethod:: ParseAsColour(str)
Parses the given string as an HTML colour.
This function recognizes the standard named HTML 4 colours as well as the usual ``RGB`` syntax.
:param `str`:
:type `str`: string
:rtype: `tuple`
:returns:
( `bool`, `clr` )
.. versionadded:: 2.9.1
.. seealso:: :meth:`wx.Colour.Set`
.. attribute:: AllParams
See :meth:`~wx.html.HtmlTag.GetAllParams`
.. attribute:: BeginPos
See :meth:`~wx.html.HtmlTag.GetBeginPos`
.. attribute:: EndPos1
See :meth:`~wx.html.HtmlTag.GetEndPos1`
.. attribute:: EndPos2
See :meth:`~wx.html.HtmlTag.GetEndPos2`
.. attribute:: Name
See :meth:`~wx.html.HtmlTag.GetName`