Random Simpsons Quote

Hi all – just got my Tidbyt today – so excited for this! Installed a few base apps, and then set myself a challenge to learn the syntax by creating a simple app to display a quote from “The Simpsons,” using this repository by Jason Luboff: http://thesimpsonsquoteapi.glitch.me

Text only for now, but I learned how to use the COLUMN and MARQUEE widgets, and also how to play with colors. I look forward to playing around with this a bit more! Currently setting up a cron job on my Mac to update this at 15 minute intervals. Code and screenshot below, feel free to steal and improve!

load("render.star", "render")
load("http.star", "http")

SIMPSONS_QUOTE_URL = "https://thesimpsonsquoteapi.glitch.me/quotes"

def main():
    rep = http.get(SIMPSONS_QUOTE_URL)
    if rep.status_code != 200:
        fail("Simpsons quote request failed with status %d", rep.status_code)

    quoted_text = []
    quoted_text = rep.json()[0]["quote"]
    character = rep.json()[0]["character"]

    return render.Root(
      render.Column(
      children=[
        render.Marquee(height=24, scroll_direction="vertical", child = render.WrappedText(content = quoted_text, color="#FED517")),
        render.Marquee(width=64, scroll_direction="horizontal", child = render.Text(content = character, color="#107dc0")),
        ],
    )
)
9 Likes

Hey just wanted to say Thank you for this snippet! I just order a Tidbyt and it’s on its way in August, but wanted to start learning how to code applets for it. I just created an Apex Legends True Level Tracker. It Displays the Account Name with their level appended to it.

1 Like