Revamp Your Olympics Leaderboard with Style! 🎨✨

Customise the Appearance of Your Olympics Leaderboard with PySimpleGUI Themes! 🎨✨

Welcome back, CodeCrafters!

In our previous post, we created an interactive Olympics leaderboard using PySimpleGUI.

Now, let's take it to the next level by customising the appearance of our leaderboard with PySimpleGUI themes.

Making your app visually appealing can greatly enhance user experience, and it’s super easy to do with PySimpleGUI.

Let’s dive in!

Step 1: Set Up Your Environment

Ensure you have PySimpleGUI installed. If you haven’t installed it yet, use the following command:

pip install pysimplegui

 

Step 2: Explore PySimpleGUI Themes

PySimpleGUI comes with a variety of pre-defined themes that you can use to change the look and feel of your app. To see the available themes, you can use the following code snippet:

import PySimpleGUI as sg

 

sg.theme_previewer()

 

This will open a window displaying all the available themes. Pick a theme you like for your leaderboard.

 

Step 3: Apply a Theme to Your App

Let’s apply a theme to our Olympics leaderboard. For this example, we’ll use the 'DarkTeal9' theme, but feel free to choose any theme you prefer.

 

import PySimpleGUI as sg

 

# Set the theme

sg.theme('DarkTeal9')

 

layout = [

    [sg.Text('Olympics Leaderboard', font=('Helvetica', 16))],

    [sg.Table(

        values=[],

        headings=['Country', 'Gold', 'Silver', 'Bronze'],

        max_col_width=25,

        auto_size_columns=True,

        display_row_numbers=False,

        justification='right',

        num_rows=10,

        key='-TABLE-',

        row_height=25)],

    [sg.Text('Country:'), sg.InputText(key='-COUNTRY-')],

    [sg.Text('Gold:'), sg.InputText(key='-GOLD-')],

    [sg.Text('Silver:'), sg.InputText(key='-SILVER-')],

    [sg.Text('Bronze:'), sg.InputText(key='-BRONZE-')],

    [sg.Button('Add/Update'), sg.Button('Exit')]

]

 

window = sg.Window('Olympics Leaderboard', layout)

 

leaderboard = {}

 

while True:

    event, values = window.read()

 

    if event sg.WIN_CLOSED or event 'Exit':

        break

 

    if event == 'Add/Update':

        country = values['-COUNTRY-']

        gold = int(values['-GOLD-'])

        silver = int(values['-SILVER-'])

        bronze = int(values['-BRONZE-'])

 

        if country:

            leaderboard[country] = [gold, silver, bronze]

            data = [[country] + leaderboard[country] for country in leaderboard]

            window['-TABLE-'].update(values=data)

 

window.close()

 

Step 4: Customize the Theme

You can further customize the theme by changing specific elements. For example, you can set custom colors for buttons, text, and other elements.

 

sg.theme('DarkTeal9')

 

# Customize specific elements

sg.set_options(button_color=('white', 'blue'), text_color='yellow')

 

layout = [

    [sg.Text('Olympics Leaderboard', font=('Helvetica', 16))],

    [sg.Table(

        values=[],

        headings=['Country', 'Gold', 'Silver', 'Bronze'],

        max_col_width=25,

        auto_size_columns=True,

        display_row_numbers=False,

        justification='right',

        num_rows=10,

        key='-TABLE-',

        row_height=25)],

    [sg.Text('Country:'), sg.InputText(key='-COUNTRY-')],

    [sg.Text('Gold:'), sg.InputText(key='-GOLD-')],

    [sg.Text('Silver:'), sg.InputText(key='-SILVER-')],

    [sg.Text('Bronze:'), sg.InputText(key='-BRONZE-')],

    [sg.Button('Add/Update'), sg.Button('Exit')]

]

 

window = sg.Window('Olympics Leaderboard', layout)

 

leaderboard = {}

 

while True:

    event, values = window.read()

 

    if event sg.WIN_CLOSED or event 'Exit':

        break

 

    if event == 'Add/Update':

        country = values['-COUNTRY-']

        gold = int(values['-GOLD-'])

        silver = int(values['-SILVER-'])

        bronze = int(values['-BRONZE-'])

 

        if country:

            leaderboard[country] = [gold, silver, bronze]

            data = [[country] + leaderboard[country] for country in leaderboard]

            window['-TABLE-'].update(values=data)

 

window.close()

 

Let’s Sum it Up!

In this post, you’ve learned how to customize the appearance of your Olympics Leaderboard using PySimpleGUI 🎨🏅.

We explored various options to enhance the visual appeal of your leaderboard, such as adjusting the layout, colors, fonts, and overall design to make your app both functional and attractive ✨.

By personalizing the look and feel of your leaderboard, you not only made it more engaging for users but also gained valuable skills in UI/UX design within PySimpleGUI 💻🎉.

This post empowered you to take control of your app’s aesthetics, making it stand out while keeping it user-friendly.

Coding with a Smile 🤣 😂

The Great Escape:

Understanding escape characters (\n, \t, etc.) feels like you’ve just learned a secret handshake. It’s your ticket to the exclusive club of programmers who can navigate strings with ease.

Let’s Inspire Future AI Coders Together! ☕

 

I’m excited to continue sharing my passion for Python programming and AI with you all. If you’ve enjoyed the content and found it helpful, do consider supporting my work with a small gift. Just click the link below to make a difference – it’s quick, easy, and every bit helps and motivates me to keep creating awesome contents for you.

Thank you for being amazing!

What’s Next? 📅

In the next post, we'll dive into the essential skills of reading and writing data to a CSV file. By mastering these techniques, you'll be able to effortlessly load your leaderboard from a file and save updates with ease, making your app more dynamic and practical. This functionality not only enhances user experience but also ensures your data is always up-to-date and accessible. Get ready to take your PySimpleGUI skills to the next level!

Ready for More Python Fun? 📬

Subscribe to our newsletter now and get a free Python cheat sheet! 📑 Dive deeper into Python programming with more exciting projects and tutorials designed just for beginners.

Keep learning, keep coding 👩‍💻👨‍💻, and keep discovering new possibilities! 💻

Enjoy your journey into artificial intelligence, machine learning, data analytics, data science and more with Python!

Stay tuned for our next exciting project in the following edition!

Happy coding!🚀📊✨

🎉 We want to hear from you! 🎉 How do you feel about our latest newsletter? Your feedback will help us make it even more awesome!

Login or Subscribe to participate in polls.