Friday, September 4, 2026
HomePythonAn Intro to Spiel - Creating Shows in Your Terminal with Python

An Intro to Spiel – Creating Shows in Your Terminal with Python


Have you ever ever wished to create a presentation in your pc’s terminal? Whereas that is an unusual want, a intelligent open supply developer has offered an answer to this drawback! The mission known as Spiel, and whereas it’s at the moment archived, the thought is fairly cool. Spiel makes use of the Wealthy package deal to create the slides in your presentation. Word: whereas the GitHub web page doesn’t clarify why the mission is archived, it seems to make use of a really outdated model of Textual which can’t be upgraded.

Let’s spend just a little time studying how this all works.

Putting in Spiel

In keeping with the Spiel GitHub web page, you may attempt Spiel with out even putting in it you probably have docker put in. Right here’s find out how to attempt Spiel:

$ docker run -it --rm ghcr.io/joshkarpel/spiel

Nevertheless, for the needs of this tutorial, you actually ought to set up Spiel. To do this, you can be utilizing pip. Open up your terminal and run the next:

pip set up spiel

Be at liberty to create a Python digital surroundings first if you happen to don’t need to set up Spiel into your world Python packages.

Upon getting Spiel put in, you may examine that it’s working by working the Spiel demo, like this:

spiel demo current

If that works, you might be good to go!

Creating Your Presentation

The documentation offers instance of find out how to create a one-slide presentation. Right here’s their instance:

from wealthy.console import RenderableType

from spiel import Deck, current

deck = Deck(title="Your Deck Identify")


@deck.slide(title="Slide 1 Title")
def slide_1() -> RenderableType:
    return "Your content material right here!"


if __name__ == "__main__":
    current(__file__)

In keeping with the documentation, there are two methods so as to add slides:

  • Use the decorator like within the instance above
  • Use `deck.add_slides()` and go in a number of Slide objects

Here’s a extra full instance that creates a few customized slides:

from wealthy.align import Align
from wealthy.console import RenderableType
from wealthy.model import Type
from wealthy.textual content import Textual content
from spiel import Deck, Slide, current


def make_slide(
    title_prefix: str,
    textual content: Textual content,
) -> Slide:
    def content material() -> RenderableType:
        return Align(textual content, align="middle", vertical="center")
    return Slide(title=f"{title_prefix} Slide", content material=content material)

deck = Deck("Check Deck")

title_slide = make_slide(title_prefix="First", textual content=Textual content("Python 101 - All About Lists",
                                             model=Type(shade="blue")))

intro_slide = make_slide(title_prefix="Second",
                    textual content=Textual content("A Python listing is",
                              model=Type(shade="crimson"))
                    )

deck.add_slides(title_slide, intro_slide)

if __name__ == "__main__":
    current(__file__)

While you run this code in your terminal, you will note one thing like this:

You possibly can transfer to the following or earlier slide utilizing the arrow keys in your keyboard. If you wish to exit, press CTRL+C.

Wrapping Up

Spiel looks as if a neat package deal. It’s a disgrace that it’s at the moment archived. Hopefully, the creator will reopen it in some unspecified time in the future, or another person will choose up the torch. Within the meantime, you may simply use it in a Python digital surroundings and provides it a attempt.

 

 

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments