TextPrintWidget

class menpowidgets.options.TextPrintWidget(text_per_line, style='minimal')[source]

Bases: FlexBox

Creates a widget for printing text. Specifically, it consists of a list of ipywidgets.Latex objects, i.e. one per text line.

Note that:

Parameters:
  • text_per_line (list of str) – The text to be printed per line.
  • style (str (see below), optional) –

    Sets a predefined style at the widget. Possible options are:

    Style Description
    'minimal' Simple black and white style
    'success' Green-based style
    'info' Blue-based style
    'warning' Yellow-based style
    'danger' Red-based style
    '' No style

Example

Let’s create an text widget and then update its state. Firstly, we need to import it:

>>> from menpowidgets.options import TextPrintWidget

Create the widget with some initial options and display it:

>>> text_per_line = ['> The', '> Menpo', '> Team']
>>> wid = TextPrintWidget(text_per_line, style='success')
>>> wid

The style of the widget can be changed as:

>>> wid.predefined_style('danger')

Update the widget state as:

>>> wid.set_widget_state(['M', 'E', 'N', 'P', 'O'])
predefined_style(style)[source]

Function that sets a predefined style on the widget.

Parameters:style (str (see below)) –

Style options:

Style Description
'minimal' Simple black and white style
'success' Green-based style
'info' Blue-based style
'warning' Yellow-based style
'danger' Red-based style
'' No style
set_widget_state(text_per_line)[source]

Method that updates the state of the widget with a new list of lines.

Parameters:text_per_line (list of str) – The text to be printed per line.
style(box_style=None, border_visible=False, border_colour='black', border_style='solid', border_width=1, border_radius=0, padding=0, margin=0, font_family='', font_size=None, font_style='', font_weight='')[source]

Function that defines the styling of the widget.

Parameters:
  • box_style (str or None (see below), optional) –

    Possible widget style options:

    'success', 'info', 'warning', 'danger', '', None
    
  • border_visible (bool, optional) – Defines whether to draw the border line around the widget.
  • border_colour (str, optional) – The colour of the border around the widget.
  • border_style (str, optional) – The line style of the border around the widget.
  • border_width (float, optional) – The line width of the border around the widget.
  • border_radius (float, optional) – The radius of the border around the widget.
  • padding (float, optional) – The padding around the widget.
  • margin (float, optional) – The margin around the widget.
  • font_family (str (see below), optional) –

    The font family to be used. Example options:

    'serif', 'sans-serif', 'cursive', 'fantasy', 'monospace',
    'helvetica'
    
  • font_size (int, optional) – The font size.
  • font_style (str (see below), optional) –

    The font style. Example options:

    'normal', 'italic', 'oblique'
    
  • font_weight (See Below, optional) –

    The font weight. Example options:

    'ultralight', 'light', 'normal', 'regular', 'book', 'medium',
    'roman', 'semibold', 'demibold', 'demi', 'bold', 'heavy',
    'extra bold', 'black'