- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I change the overall theme of a tkinter application?
The ttk themed widget in Tkinter is introduced to design the external properties and styles of a widget in application. The ttk uses Tcl/Tk interpreter to give the user access to the interface that has many inbuilt attributes and features useful for any widget or application. Now, if we compare Ttk themes with Tcl themes, there are lots of variations in it.
Ttk generally supports only a few themes which are as follows −
- winnative
- clam
- alt
- default
- classic
- vista
- xpnative
In order to change the overall theme of a tkinter application, we have to use the style.theme_use(theme_name) function.
Example
# Import the required libraries in tkinter from tkinter import * from tkinter import ttk from tkinter import messagebox # Create an instance of tkinter frame or window win = Tk() # Set the size of tkinter window win.geometry("700x350") # Create an instance of ttk Style style = ttk.Style() # Configure the theme with style style.theme_use('clam') # Define a function to show the message def display_msg(): messagebox.showinfo("Message", "You are learning Python Tkinter!") # Add a Customized Label widget label = ttk.Label(win, text="Hey Folks, I have a Message for You!", font=('Aerial 16')) label.pack(pady=5) # Add a Button widget ttk.Button(win, text="Show Message", command=display_msg).place(x=285, y=98) win.mainloop()
Output
Running the above code will open a window with a label widget and a button. The overall theme of the application is defined by ttk themed widget. We can configure the theme from the list of available themes in tkinter library
- Related Articles
- How do I change the background of a Frame in Tkinter?
- How do I change current theme at runtime in my android app?
- How do I change button size in Python Tkinter?
- Python Tkinter – How do I change the text size in a label widget?
- How do I change the Tkinter default title in the OS bar?
- When do I need to call the main loop in a Tkinter application?
- How to change Firefox Browser theme?
- How do I close a tkinter window?
- How can I change the text of the Tkinter Listbox item?
- How do I position the buttons on a Tkinter window?
- How do I get the background color of a Tkinter Canvas widget?
- How do I get the 'state' of a Tkinter Checkbutton?
- How do I get the width and height of a Tkinter window?
- How to change theme for AlertDialog on Android?
- How do I create a popup window in Tkinter?
