Node for the header of the website.
It contains the welcome message and the accessibility buttons.
Node for the header of the website.
It contains the welcome message and the accessibility buttons.
Create the header node.
def __init__(self, parent: str, content_filename: str | None=None):
"""Create the header node.
:param parent: (str) The parent node identifier
:param content_filename: (str) The HTML content filename
"""
super(WhakerKitHeaderNode, self).__init__(parent)
self.reset(content_filename)
self.set_attribute('id', 'header-content')
Reset the header to its default values.
def reset(self, filename: str | None=None):
"""Reset the header to its default values.
:param filename: (str | None) The filename to use for the header content
"""
self.clear_children()
a = HTMLNode(self.identifier, None, 'a', value=get_msg(MSG_SKIP))
a.set_attribute('role', 'button')
a.set_attribute('class', 'skip')
a.set_attribute('href', '#main-content')
self.append_child(a)
if filename is not None and os.path.exists(filename) is True:
with open(filename, encoding='utf-8') as html_file:
content = html_file.read()
if len(content.strip()) > 0:
self.set_value(content.strip())
nav = WhakerKitAccessibilityNavNode(self.identifier)
self.append_child(nav)