plie package

Submodules

plie.helper_functions module

plie.helper_functions.backgrounder(bounds, cells=None, background='.')[source]
Replace all empty cells with the specified background cell,
or fill size bounds with background str

Notes

‘empty’ cells means cells with actually nothing in them, cells with spaces in them will be left unmodified.

Parameters:
  • bounds – of the region to background, in format (width, height)
  • cells – dictionary of cells with keys of style (x,y)
  • background – the character to replace empty cells with

Returns: a cell space dictionary with empty cells replaced

plie.helper_functions.borderer(bounds, cells=None, border_style='default')[source]

Creates a border around an area of the given size

borderer will work with either just a size parameter, producing only the cells for the border, or for applying a border to an already filled cell space

Parameters:
  • bounds – the width and height of the area to apply a border to
  • cells – dict of cells, with keys of format (x,y) and values as single character strings
  • border_style – specifies which border style to use

Returns: a cell space dict that now has a border around it

plie.mutlitext module

class plie.mutlitext.MultiText(texts=(), bullet_choice='', justify='left', bounds=None)[source]

Bases: plie.text.Text

MultiText displays sequences of text, including bulleted lists.

MultiText can be used for lists of text, menus, and other things that involve multiple distinct elements of vertically arranged text.

Parameters:
  • texts – sequence of text strings to display (preferably immutable)
  • bullet_choice – a string that will be used as the bullet for each list item
  • justify – which justification to use for the list items
  • bounds – bounding box specifying size in cells (x,y), usually set by Renderer
__str__()[source]

creates a printable string of this instance

Individual texts in in the MultiText instance are prefixed with self.bullet_choice, multiline texts have subsequent lines indented to where they start at an equal indent to the first line

Returns: a printable string of the contents of this instance

as_cells()[source]

Translates the internal state into a cell space based format for transferring

Returns: a dictionary cell space representation of all the contained text objects

update(bounds=None, texts=None, specific_text=(), bullet_choice=None)[source]

For changing internal state

Parameters:
  • bounds – update the bounds, either a tuple or a Bounds object
  • texts – update the entire list of texts
  • specific_text – a tuple of format (new_text_string, index)
  • bullet_choice – update the bullet_choice

Returns: nothing, but updates the internal state

plie.renderer module

class plie.renderer.Renderer(size=None, view=None)[source]

Bases: object

add_view(view)[source]

Take in a valid view dict, and initialize anything that needs initializing, then store it ready for displaying

Notes

To initialize in this context means find the size for each Renderable, by examining the bounds, padding and positioning. So that when the Renderable is initialized, it can start at the appropriate size. The instance of the Renderable for each renderable section then gets added to that section.

Sections get turned into ChainMaps, if they share a name with any of the default sections, they can inherit attributes from that default.

Parameters:view – a valid view dict

Returns: nothing, but adds an initialized view to the ChainMap

composite(cellspace, position=(0, 0))[source]

Given a cellspace and position, add that to the internal dict at the correct position.

Parameters:
  • cellspace – a cell space dictionary representation of a view object
  • position – where the top left corner should go
display(update=True)[source]

Display fullscreen out to the terminal.

Parameters:update – whether or not to update before displaying

Notes

Uses Blessed for fullscreen terminal support.

formulate()[source]

Turns the internal dictionary into a string for rendering.

Returns: A string that could render the whole screen if printed.

update()[source]

Updates the internal dictionary representation

class plie.renderer.RendererOld(size=None, view=None)[source]

Bases: object

The thing that translates Views and View objects into actual text on the screen.

Parameters:
  • size – a tuple like, (width, height) in cells, if not specified Renderer will use the full terminal size
  • view – a View instance
add_view(view)[source]

Add a view to the view stack, with a blank view underneath it if needed.

Parameters:view – a View instance to add to the internal stack of Views
composite(view_object_dict, position=(0, 0), size=(0, 0))[source]

given a view_object represented as a dictionary of cells of size and position, add that to the internal dict, at the correct position.

Parameters:
  • view_object_dict – a cell space dictionary representation of a view object
  • position – where the top left corner should go
  • size – how big it is
display()[source]

Go through the view on the top of the view stack, and add everything it contains to the dict.

formulate()[source]

Turns the internal dictionary into a string for rendering.

Returns: A string that could render the whole screen if printed.

update()[source]

Update the internal dictionary cell space representation to match what’s currently on the view stack

plie.styles module

Repository of all adjustable styles

plie.text module

class plie.text.Text(text='', callout=None, justify='left', bounds=None, replace_whitespace=True)[source]

Bases: object

Text is the universal class for dealing with all single text snippets.

Text helps with basic formatting, justification, word wrapping to the appropriate width and acts as a way to contain a block of text for applying styles to it or developing a layout.

Parameters:
  • text – the text to display (can be changed later
  • callout – an attribute made available for storing a function, it is used if this Text object gets selected by some event.
  • justify – specifies which justification the text should have, options are: ‘left’ where all the text aligns with the left edge, ‘center’ where all the text is centered in the middle of the, available space ‘right’ where all the text aligns with the right edge
  • bounds – the bounding box for the Text object in screen space cells, will be set automatically by Renderer usually

Returns: an initialized Text object

as_cells()[source]

Translates the internal state and translates it into a screen-space cell dict of size bounds

Returns: Dictionary with keys of format (x,y), of size bounds and single character strings as the values.

lines

Returns: the number of lines that the Text instance uses

update(bounds=None, text=None, **kwargs)[source]

For changing internal state, including updating the text to display.

update() accepts **kwargs, so any keyword argument passed during initialization can be passed again, to change the stored value.

Returns: True if updating went well

Module contents