How to use a dark theme in tkinter

In this repository you will get all you need to have the following window https://github.com/formazione/tkinter_dark_theme

Check my post about azure theme.

This is the code.

import tkinter as tk
import tkinter.ttk as ttk



def darkstyle(root):
    ''' Return a dark style to the window'''
    
    style = ttk.Style(root)
    root.tk.call('source', 'azure dark/azure dark.tcl')
    style.theme_use('azure')
    style.configure("Accentbutton", foreground='white')
    style.configure("Togglebutton", foreground='white')
    return style

def main_window():
    """ The window with the darkstyle """
    root = tk.Tk()
    root.title("My App")
    root.resizable(False, False)
    img = tk.PhotoImage(file="001.png")

    style = darkstyle(root)


    lab = ttk.Label(
        root,
        text="Hello World",
        compound="center",
        font="arial 50",
        image=img)
    lab.pack(fill="both", expand=1)


    button = ttk.Button(
        root,
        text="Click me",
        style="Accentbutton"
        )

    button.place(relx=0.43, rely=0.7, width=100, height=30)


    root.mainloop()

main_window()

Have fun with tkinter

This is a video about the azure theme.


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.