wx.html.HtmlTag¶
This class represents a single HTML tag.
It is used by tag handlers.
Class Hierarchy¶
Methods Summary¶
Returns a string containing all parameters. |
|
Returns tag’s name. |
|
Returns the value of the parameter. |
|
Interprets tag parameter par as colour specification and saves its value into wx.Colour variable pointed by clr. |
|
Interprets tag parameter par as an integer and saves its value into int variable pointed by value. |
|
Get the value of the parameter. |
|
Returns |
|
Returns |
|
Parses the given string as an HTML colour. |
Properties Summary¶
See |
|
See |
Class API¶
- class wx.html.HtmlTag(object)¶
This class represents a single HTML tag.
Methods¶
- GetAllParams(self)¶
Returns a string containing all parameters.
Example: tag contains <FONT SIZE=+2 COLOR=”#000000”>. Call to tag.GetAllParams() would return
'SIZE=+2
COLOR=”#000000”’.- Return type:
str
- GetName(self)¶
Returns tag’s name.
The name is always in uppercase and it doesn’t contain “ or ‘/’ characters. (So the name of <FONT SIZE=+2> tag is “FONT” and name of </table> is “
TABLE
”).- Return type:
str
- GetParam(self, par, with_quotes=False)¶
Returns the value of the parameter.
You should check whether the parameter exists or not (use
wx.html.HtmlTag.HasParam
) first or useGetParamAsString
if you need to distinguish between non-specified and empty parameter values.- Parameters:
par (string) – The parameter’s name.
with_quotes (bool) –
True
if you want to get quotes as well. See example.
- Return type:
str
# ... Some code here... # you have wx.HtmlTag variable tag which is equal to the # HTML tag <FONT SIZE=+2 COLOR="#0000FF"> dummy = tag.GetParam("SIZE") # dummy == "+2" dummy = tag.GetParam("COLOR") # dummy == "#0000FF" dummy = tag.GetParam("COLOR", true) # dummy == "\"#0000FF\"" -- see the difference!!
- GetParamAsColour(self, par)¶
Interprets tag parameter par as colour specification and saves its value into wx.Colour variable pointed by clr.
Returns
True
on success andFalse
if par is not colour specification or if the tag has no such parameter.- Parameters:
par (string)
- Return type:
le[bool, wx.Colour]
See also
- GetParamAsInt(self, par)¶
Interprets tag parameter par as an integer and saves its value into int variable pointed by value.
Returns
True
on success andFalse
if par is not an integer or if the tag has no such parameter.- Parameters:
par (string)
- Return type:
Tuple[bool, int]
- 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 returnsTrue
.- Parameters:
par (string) – The parameter’s name.
value (string) – Pointer to the string to be filled with the parameter value, must be not
None
.
- Return type:
bool
Added in version 3.0.
- HasEnding(self)¶
Returns
True
if this tag is paired with ending tag,False
otherwise.See the example of HTML document:
<html><body> Hello<p> How are you? <p align=center>This is centered...</p> Oops<br>Oooops! </body></html>
In this example tags HTML and
BODY
have ending tags, first P andBR
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.- Return type:
bool
- HasParam(self, par)¶
Returns
True
if the tag has a parameter of the given name.Example: <FONT SIZE=+2 COLOR=”\#FF00FF”> has two parameters named “SIZE” and “COLOR”.
- Parameters:
par (string) – the parameter you’re looking for.
- Return type:
bool
- static 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.- Parameters:
str (string)
- Return type:
le[bool, wx.Colour]
- Returns:
True
if the string was successfully parsed and clr was filled with the result orFalse
otherwise.
Added in version 2.9.1.
See also
Properties¶
- AllParams¶
See
GetAllParams