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()[source]

Reload the input, keeping the current slide in focus

run()[source]
update()[source]
update_body()[source]

Render the provided slide body

update_creation()[source]

Update the author and date

update_slide_num()[source]

Update the slide number

update_title()[source]

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):
    pass

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.
flush_cache()[source]

Clea everything out of the queue and the cache.

get_slide(slide_number)[source]

Fetch the slide from the cache

queue_render(slide)[source]

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()[source]

Run the main render thread

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

Run the provided presentation

Parameters:start_slide (int) – 0-based slide index
lookatme.tui.text(style, data, align='left')[source]