hikarimusic / Azure-ttk-theme

Azure theme is a beautiful and modern ttk theme, inspired by Fluent design

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure theme for ttk

Warnings!

Relicensing

Any release below 2.0 is licnsed under the LGPL v2.1 license.

Any release above version 2.0 is licensed under the MIT license!

Please pay attention to which terms and conditions apply to the release you using!

Theme refactored

There were plenty of big changes and improvements in version 2.0. This affected, among other things, the way of setting a theme and additional widget style naming! If you want/have to use a different theme setting method or widget style naming, please use version 1.4.1.

New widget style names:

New name Old name
Accent.TButton AccentButton
Toggle.TButton ToggleButton
Switch.TCheckbutton Switch
Tick.TScale TickScale
Card.TFrame Card

image image

How to use?

Just like for my Sun Valley theme in version 2.0 I wanted to make usage of the theme very simple, so the theme setting is handled by a separate tcl script. This way whether you want to use a dark or light theme, you need to import just a single file. The other thing that makes this a good solution is that normally switching between light and dark theme is not entirely perfect, and the colors are not correct.

# Just simply import the azure.tcl file
widget.tk.call("source", "azure.tcl")

# Then set the theme you want with the set_theme procedure
widget.tk.call("set_theme", "light")
# or
widget.tk.call("set_theme", "dark")

Changing themes

Normally changing between themes isn't that easy, because then the colors aren't correct. See this Stackoverflow question. However, with my current solution, you can change theme at any time, without any color issues.

import tkinter as tk
from tkinter import ttk

root = tk.Tk()

# Pack a big frame so, it behaves like the window background
big_frame = ttk.Frame(root)
big_frame.pack(fill="both", expand=True)

# Set the initial theme
root.tk.call("source", "azure.tcl")
root.tk.call("set_theme", "light")

def change_theme():
    # NOTE: The theme's real name is azure-<mode>
    if root.tk.call("ttk::style", "theme", "use") == "azure-dark":
        # Set light theme
        root.tk.call("set_theme", "light")
    else:
        # Set dark theme
        root.tk.call("set_theme", "dark")

# Remember, you have to use ttk widgets
button = ttk.Button(big_frame, text="Change theme!", command=change_theme)
button.pack()

root.mainloop()

New style elements

Azure theme has a style for every ttk widget, but there are some new widget styles, such as an accent button, toggle switch, toggle button, tickscale, and card. You can apply these with the style parameter.

If you need a highlighted button, use Accent.TButton:

button = ttk.Button(root, text='Accent button', style='Accent.TButton', command=callback)

To create a toggle button you need a checkbutton, to which you can apply the ToggleButton style:

togglebutton = ttk.Checkbutton(root, text='Toggle button', style='Toggle.TButton', variable=var)

The use of switches is becoming more common these days, so this theme has a Switch style, that can be applied to checkbuttons:

switch = ttk.Checkbutton(root, text='Switch', style='Switch.TCheckbutton', variable=var)

If you don't like the big circle on the scale, you prefer something more solid, then use the TickScale style:

scale = ttk.Scale(root, style='Tick.TScale', variable=var)

If you only want a border around your widgets, not an entire LabelFrame then apply the Card style to a Frame:

card = ttk.Frame(root, style='Card.TFrame', padding=(5, 6, 7, 8))

Bugs

  • Tk isn't really good at displaying png images, so if your program is laggy with the theme, please check out the gif-based branch!
  • When you change the theme, the window resizes. This is a quite strange bug that applies to all ttk themes.

If you scrolled down here, please check out my other themes!

About

Azure theme is a beautiful and modern ttk theme, inspired by Fluent design

License:MIT License


Languages

Language:Tcl 78.0%Language:Python 22.0%