This class represents a single HTML tag.
It is used by tag handlers.
GetAllParams |
Returns a string containing all parameters. |
GetBeginPos |
Returns beginning position of the text between this tag and paired ending tag. |
GetEndPos1 |
Returns ending position of the text between this tag and paired ending tag. |
GetEndPos2 |
Returns ending position 2 of the text between this tag and paired ending tag. |
GetName |
Returns tag’s name. |
GetParam |
Returns the value of the parameter. |
GetParamAsColour |
Interprets tag parameter par as colour specification and saves its value into wx.Colour variable pointed by clr. |
GetParamAsInt |
Interprets tag parameter par as an integer and saves its value into int variable pointed by value. |
GetParamAsString |
Get the value of the parameter. |
HasEnding |
Returns True if this tag is paired with ending tag, False otherwise. |
HasParam |
Returns True if the tag has a parameter of the given name. |
ParseAsColour |
Parses the given string as an HTML colour. |
AllParams |
See GetAllParams |
BeginPos |
See GetBeginPos |
EndPos1 |
See GetEndPos1 |
EndPos2 |
See GetEndPos2 |
Name |
See GetName |
wx.html.
HtmlTag
(object)¶This class represents a single HTML tag.
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: | string |
---|
GetBeginPos
(self)¶Returns beginning position of the text between this tag and paired ending tag.
See explanation (returned position is marked with ‘|’):
bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|
Return type: | int |
---|
Todo
provide deprecation description
GetEndPos1
(self)¶Returns ending position of the text between this tag and paired ending tag.
See explanation (returned position is marked with ‘|’):
bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|
Return type: | int |
---|
Todo
provide deprecation description
GetEndPos2
(self)¶Returns ending position 2 of the text between this tag and paired ending tag.
See explanation (returned position is marked with ‘|’):
bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|
Return type: | int |
---|
Todo
provide deprecation description
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: | string |
---|
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 use GetParamAsString
if you need to distinguish between non-specified and empty parameter values.
Parameters: |
|
---|---|
Return type: |
|
# ... 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 and False
if par is not colour specification or if the tag has no such parameter.
Parameters: | par (string) – |
---|---|
Return type: | tuple |
Returns: | ( bool, clr ) |
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 and False
if par is not an integer or if the tag has no such parameter.
Parameters: | par (string) – |
---|---|
Return type: | tuple |
Returns: | ( bool, value ) |
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
.
Parameters: |
|
---|---|
Return type: | bool |
New 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 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.
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 |
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: | tuple |
Returns: | ( bool, clr ) |
New in version 2.9.1.
See also
AllParams
¶See GetAllParams
BeginPos
¶See GetBeginPos
EndPos1
¶See GetEndPos1
EndPos2
¶See GetEndPos2