Represent a button element.
The set_attribute method should be overridden to check if the given key is in the list of accepted attributes.
Represent a button element.
The set_attribute method should be overridden to check if the given key is in the list of accepted attributes.
Create an input node. Default type is 'text'.
def __init__(self, parent, identifier, attributes=dict()):
"""Create an input node. Default type is 'text'.
"""
super(HTMLButtonNode, self).__init__(parent, identifier, 'button', attributes=attributes)
if 'id' not in attributes:
self.add_attribute('id', self.identifier)
if 'name' not in attributes:
self.add_attribute('name', self.identifier)
if 'type' not in attributes:
self.add_attribute('type', 'button')
Set an icon to the button from its filename.
def set_icon(self, icon, attributes=dict()):
"""Set an icon to the button from its filename.
:param icon: (str) Name of an icon in the app.
:param attributes: (dict).
"""
node = HTMLImage(self.identifier, None, src=icon)
if len(attributes) > 0:
for key in attributes:
node.set_attribute(key, attributes[key])
self.append_child(node)
return node
Set a text to the button.
def set_text(self, ident, text, attributes=dict()):
"""Set a text to the button.
:param ident: (str) Identifier for the span text.
:param text: (str) Button text.
:param attributes: (dict)
"""
node = HTMLNode(self.identifier, ident, 'span', value=text, attributes=attributes)
if ident is not None:
node.set_attribute('id', ident)
self.append_child(node)
if ident is not None:
self.set_attribute('aria-labelledby', node.identifier)
return node