WhakerPy 0.8

https://sourceforge.net/projects/whakerpy/

Module whakerpy.htmlmaker

Class HTMLRadioBox

Description

Represent a form with one or several input of radio type.

Constructor

Create a form node.

Parameters
  • parent
  • identifier
View Source
def __init__(self, parent, identifier):
    """Create a form node."""
    attributes = dict()
    attributes['method'] = 'POST'
    attributes['name'] = identifier
    attributes['id'] = identifier
    super(HTMLRadioBox, self).__init__(parent, identifier, 'form', attributes=attributes)

Public functions

append_input

Append a label tag with an input and a span.

Parameters
  • class_name: (str) Used for both the CSS class of the label and the name of the input
  • value: (str) input value
  • text: (str) span tag content
  • checked: (bool)
View Source
def append_input(self, class_name, value, text=None, checked=False):
    """Append a label tag with an input and a span.

        :param class_name: (str) Used for both the CSS class of the label and the name of the input
        :param value: (str) input value
        :param text: (str) span tag content
        :param checked: (bool)

        """
    label_attributes = dict()
    label_attributes['class'] = str(class_name)
    if 'button' not in class_name:
        label_attributes['class'] = 'button ' + class_name
    if checked is True:
        label_attributes['class'] += ' checked'
    label_node = HTMLNode(self.identifier, None, 'label', attributes=label_attributes)
    self.append_child(label_node)
    input_attributes = dict()
    input_attributes['type'] = 'radio'
    input_attributes['name'] = class_name
    input_attributes['value'] = value
    if checked is True:
        input_attributes['checked'] = None
    input_node = BaseTagNode(label_node.identifier, None, 'input', attributes=input_attributes)
    label_node.append_child(input_node)
    if text is not None:
        span_node = HTMLNode(label_node.identifier, None, 'span', value=text)
    else:
        span_node = HTMLNode(label_node.identifier, None, 'span', value=value)
    label_node.append_child(span_node)