Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Tkinter GUI Application Development Blueprints

You're reading from  Tkinter GUI Application Development Blueprints

Product type Book
Published in Nov 2015
Publisher Packt
ISBN-13 9781785889738
Pages 340 pages
Edition 1st Edition
Languages
Author (1):
Bhaskar Chaudhary Bhaskar Chaudhary
Profile icon Bhaskar Chaudhary

Table of Contents (15) Chapters

Tkinter GUI Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Meet Tkinter 2. Making a Text Editor 3. Programmable Drum Machine 4. A Game of Chess 5. Building an Audio Player 6. Paint Application 7. Multiple Fun Projects 8. Miscellaneous Tips Index

Adding themes


You may recall that while defining the Themes menu, we defined a color scheme dictionary containing the name and hexadecimal color codes as a key-value pair, as follows:

color_schemes = { 
'Default': '#000000.#FFFFFF',
'Greygarious':'#83406A.#D1D4D1',
'Aquamarine': '#5B8340.#D1E7E0',
'Bold Beige': '#4B4620.#FFF0E1',
'Cobalt Blue':'#ffffBB.#3333aa',
'Olive Green': '#D1E7E0.#5B8340',
'Night Mode': '#FFFFFF.#000000',
}

The theme choice menu has already been defined. Let's add a command callback to handle the selected menu (refer to 2.12.py in the code bundle):

themes_menu.add_radiobutton(label=k, variable=theme_choice, command=change_theme)

Finally, let's define the change_theme function to handle the changing of themes, as follows:

def change_theme(event=None):
    selected_theme = theme_choice.get()
    fg_bg_colors = color_schemes.get(selected_theme)
    foreground_color, background_color = fg_bg_colors.split('.')
    content_text.config(background=background_color, fg=foreground_color...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}