What is a Story

A Story is an interactive document similar to Jupyter Notebook. You can create a Story through the Python Playground editor by importing the story library. A Story is composed of widgets, each of which is functional to a specific use. We will now analyze the following widgets:

  • Text
  • Whiteboard

Usage

To use the library, import it as follows:

from story import create

Main Classes

Story

The main class that manages the presentation.

Methods

  • sleep(time): Adds a pause to the presentation.
  • text(): Creates a new Text object.
  • whiteboard(width=500, height=500): Creates a new Whiteboard object.
  • run(): Runs the presentation.

Text

Class to manage text elements in the presentation.

Methods

  • write(markdown): Writes text in Markdown format.

Whiteboard

Class to create and manipulate a whiteboard.

Methods

  • draw(x, y, width, height, color="red"): Draws a rectangle on the board.
  • text(x, y, text, color="black", font="15px serif"): Writes text on the board.
  • clean(): Cleans the board, filling it with white.

Example

from story import create

# Create a new story
story = create()

# Add items to the story
story.text().write("# Welcome to my presentation")
story.sleep(1)
story.text().write("This is an example of text")

# Create a whiteboard
wb = story.whiteboard(400, 300)
wb.draw(50, 50, 100, 100, "blue")
wb.text(60, 80, "Hello!", "white")

# Run the presentation
await story.run()
Run