lookatme.tui module

This module defines the text user interface (TUI) for lookatme

class lookatme.tui.MarkdownTui(pres, start_idx=0)[source]

Bases: urwid.container.Frame

keypress(size, key)[source]

Handle keypress events

prep_pres(pres, start_idx=0)[source]

Prepare the presentation for displaying/use


Reload the input, keeping the current slide in focus


Render the provided slide body


Update the author and date


Update the slide number


Update the slide margins and paddings


Update the title

class lookatme.tui.SlideRenderer(loop)[source]

Bases: threading.Thread

daemon = True
do_render(to_render, slide_num)[source]

Perform the actual rendering of a slide. This is done by:

  • parsing the slide into tokens (should have occurred already)
  • iterating through each parsed markdown token
  • calling the appropriately-named render function for the token["type"] in lookatme.render.markdown_block

Each render function must have the signature:

def render_XXX(token, body, stack, loop):

The arguments to the render function are described below:

  • token - the lexed markdown token - a dictionary
  • body - the current urwid.Pile() that return values will be added to (same as stack[-1])
  • stack - The stack of urwid.Pile() used during rendering. E.g., when rendering nested lists, each nested list will push a new urwid.Pile() to the stack, each wrapped with its own additional indentation.
  • loop - the urwid.MainLoop instance being used by lookatme. This won’t usually be used, but is available if needed.

Main render functions (those defined in markdown_block.py) may have three types of return values:

  • None - nothing is added to stack[-1]. Perhaps the render function only needed to add additional indentation by pushing a new urwid.Pile() to the stack.
  • list(urwid.Widget) - A list of widgets to render. These will automatically be added to the Pile at stack[-1]
  • urwid.Widget - A single widget to render. Will be added to stack[-1] automatically.

Clea everything out of the queue and the cache.


Fetch the slide from the cache


Queue up a slide to be rendered.

render_slide(slide, force=False)[source]

Render a slide, blocking until the slide completes. If force is True, rerender the slide even if it is in the cache.


Run the main render thread

lookatme.tui.create_tui(pres, start_slide=0)[source]

Run the provided presentation

Parameters:start_slide (int) – 0-based slide index

This function is overridable by contrib extensions that need to specify the root urwid widget.

The return value must return either the to_wrap widget itself, or another widget that wraps the provided to_wrap widget.

lookatme.tui.text(style, data, align='left')[source]