Web Analytics Made Easy - Statcounter
Skip to content

Theme Browser

This Recipe is a "Theme Browser" that enables you to see the different color schemes.

You're first shown this window that lists all of the available "Theme" settings. This window was created after the Theme were set to "Dark Brown".


If you click on an item in the list, you will immediately get a popup window that is created using the new Theme.


import PySimpleGUI as sg

    Allows you to "browse" through the Theme settings.  Click on one and you'll see a
    Popup window using the color scheme you chose.  It's a simple little program that also demonstrates
    how snappy a GUI can feel if you enable an element's events rather than waiting on a button click.
    In this program, as soon as a listbox entry is clicked, the read returns.

sg.theme('Dark Brown')

layout = [[sg.Text('Theme Browser')],
          [sg.Text('Click a Theme color to see demo window')],
          [sg.Listbox(values=sg.theme_list(), size=(20, 12), key='-LIST-', enable_events=True)],

window = sg.Window('Theme Browser', layout)

while True:  # Event Loop
    event, values = window.read()
    if event in (sg.WIN_CLOSED, 'Exit'):
    sg.popup_get_text('This is {}'.format(values['-LIST-'][0]))


Making Changes to Themes & Adding Your Own Themes

Modifying and creating your own theme is not difficult, but tricky so start with something and modify it carefully.

The tkinter port has the theme_add_new function that will add a new dictionary entry into the table with the name you provide. It takes 2 parameters - the theme name and the dictionary entry.

The manual way to add a dictionary entry is as follows....

The Theme definitions are stored in a dictionary. The underlying dictionary can be directly accessed via the variable LOOK_AND_FEEL_TABLE.

A single entry in this dictionary has this format (copy this code):

 'LightGreen3': {'BACKGROUND': '#A8C1B4',
               'TEXT': 'black',
               'INPUT': '#DDE0DE',
               'SCROLL': '#E3E3E3',
               'TEXT_INPUT': 'black',
               'BUTTON': ('white', '#6D9F85'),
               'BORDER': 1,
               'SLIDER_DEPTH': 0,
               'PROGRESS_DEPTH': 0}

As you can see, a single entry in the Look and Feel dictionary is itself a dictionary.