How to use the "native" GUI look with Tkinter?

We generally use Tkinter to develop standard GUI-based applications with default style and theme applied to all the widgets in it. To change the overall style of the application GUI, we use the ttk package. The Tkinter ttk is a themed widget which is used to style the tkinter widgets. It provides a native GUI look to the widget.

The themed widget has many inbuilt functions and features which are accessible and can be used thoroughly in the application. ttk works in the same way as CSS does for an HTML page. You can use ttk either by importing directly or by instantiating an object of ttk.

Basic TTK Style Implementation

Here's how to create a native-looking GUI using ttk styling ?

# Import the tkinter library
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()

# Set the size of the Tkinter window
win.geometry("700x350")
win.title("Native GUI with TTK")

# Create an instance of ttk
s = ttk.Style()

# Use the window native theme
s.theme_use('winnative')

# Add a label text
label = Label(win, text="Eat-Sleep, Code Repeat", font=('Arial', 16), background="green3")
label.pack(pady=30)

# Create ttk styled widgets
ttk.Button(win, text="TTK Button").pack(pady=10)
ttk.Entry(win).pack(pady=10)

win.mainloop()

Available TTK Themes

You can check and use different available themes ?

from tkinter import *
from tkinter import ttk

win = Tk()
win.geometry("400x300")

s = ttk.Style()

# Print available themes
print("Available themes:", s.theme_names())

# Try different themes
themes = ['clam', 'alt', 'default', 'classic']
for theme in themes:
    if theme in s.theme_names():
        print(f"Using theme: {theme}")
        s.theme_use(theme)
        break

# Create themed widgets
ttk.Label(win, text="Themed Label").pack(pady=10)
ttk.Button(win, text="Themed Button").pack(pady=10)
ttk.Progressbar(win, length=200).pack(pady=10)

win.mainloop()

Customizing TTK Styles

You can create custom styles for specific widget types ?

from tkinter import *
from tkinter import ttk

win = Tk()
win.geometry("500x400")

s = ttk.Style()
s.theme_use('clam')

# Configure custom button style
s.configure('Custom.TButton',
           foreground='white',
           background='blue',
           font=('Arial', 12, 'bold'))

# Configure custom label style  
s.configure('Custom.TLabel',
           foreground='darkgreen',
           background='lightgray',
           font=('Arial', 14))

# Apply custom styles
ttk.Label(win, text="Custom Styled Label", style='Custom.TLabel').pack(pady=20)
ttk.Button(win, text="Custom Styled Button", style='Custom.TButton').pack(pady=20)

# Regular ttk widgets for comparison
ttk.Label(win, text="Regular TTK Label").pack(pady=10)
ttk.Button(win, text="Regular TTK Button").pack(pady=10)

win.mainloop()

Common TTK Themes

Theme Name Platform Description
winnative Windows Native Windows look
aqua macOS Native macOS look
clam Cross-platform Clean, modern appearance
alt Cross-platform Alternative styling

Conclusion

TTK provides native GUI styling for Tkinter applications. Use ttk.Style().theme_use() to apply system themes, and configure custom styles for professional-looking interfaces. TTK widgets automatically adapt to the operating system's native appearance.

Updated on: 2026-03-25T22:21:50+05:30

751 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements