# lookatme.tui module

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

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

  Bases: `Frame`

  keypress(size, key)

    Handle keypress events

  prep_pres(pres, start_idx=0)

    Prepare the presentation for displaying/use

  reload()

    Reload the input, keeping the current slide in focus

  run()
  update()
  update_body()

    Render the provided slide body

  update_creation()

    Update the author and date

  update_slide_num()

    Update the slide number

  update_slide_settings()

    Update the slide margins and paddings

  update_title()

    Update the title

class lookatme.tui.SlideRenderer(loop)

  Bases: `Thread`

  daemon = True
  do_render(to_render, slide_num)

    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()

    Clea everything out of the queue and the cache.

  queue_render(slide)

    Queue up a slide to be rendered.

  render_slide(slide, force=False)

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

  run()

    Run the main render thread

  stop()

lookatme.tui.create_tui(pres, start_slide=0)

  Run the provided presentation

  Parameters:

    start_slide (int) – 0-based slide index

lookatme.tui.root_urwid_widget(to_wrap)

  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')