MenuComponent¶
-
class
consolemenu.menu_component.
MenuComponent
(menu_style, max_dimension=None)[source]¶ Base class for a menu component.
Parameters: - menu_style (
MenuStyle
) – the style for this component. - max_dimension (
Dimension
) – the maximum Dimension (width x height) for the menu. Defaults to width=80 and height=40 if not specified.
Raises: TypeError – if menu_style is not a
MenuStyle
.-
border_style
¶ The border style for this component.
Type: consolemenu.format.MenuBorderStyle
-
calculate_border_width
()[source]¶ Calculate the width of the menu border. This will be the width of the maximum allowable dimensions (usually the screen size), minus the left and right margins and the newline character. For example, given a maximum width of 80 characters, with left and right margins both set to 1, the border width would be 77 (80 - 1 - 1 - 1 = 77).
Returns: the menu border width in columns. Return type: int
-
calculate_content_width
()[source]¶ Calculate the width of inner content of the border. This will be the width of the menu borders, minus the left and right padding, and minus the two vertical border characters. For example, given a border width of 77, with left and right margins each set to 2, the content width would be 71 (77 - 2 - 2 - 2 = 71).
Returns: the inner content width in columns. Return type: int
-
generate
()[source]¶ Generate this component.
Yields: str – The next string of characters for drawing this component.
-
inner_horizontal_border
()[source]¶ The complete inner horizontal border section, including the left and right border verticals.
Returns: The complete inner horizontal border. Return type: str
-
inner_horizontals
()[source]¶ The string of inner horizontal border characters of the required length for this component (not including the menu margins or verticals).
Returns: The inner horizontal characters. Return type: str
-
margins
¶ The margins for this component.
Type: consolemenu.format.MenuMargins
-
outer_horizontal_border_bottom
()[source]¶ The complete outer bottom horizontal border section, including left and right margins.
Returns: The bottom menu border. Return type: str
-
outer_horizontal_border_top
()[source]¶ The complete outer top horizontal border section, including left and right margins.
Returns: The top menu border. Return type: str
-
outer_horizontals
()[source]¶ The string of outer horizontal border characters of the required length for this component (not including the menu margins or verticals).
Returns: The outer horizontal characters. Return type: str
-
padding
¶ The padding for this component.
Type: consolemenu.format.MenuPadding
-
row
(content='', align='left', indent_len=0)[source]¶ A row of the menu, which comprises the left and right verticals plus the given content. If the content is larger than the alloted space for a single row, the content is wrapped onto multiple lines, while also respecting user-included newline characters.
Returns: One or more rows of this menu component with the specified content. Return type: str
-
style
¶ The style for this component.
Type: consolemenu.format.MenuStyle
- menu_style (