Skip to main content

This library helps you to set style to tkinter default widget using stylesheet with ease.

Project description

Tkinter stylesheet - Tkss

License: MIT

This library helps you to set style to tkinter default widget using stylesheet without much work.

Quick Example:

from tkinter import *
from tkstylesheet import TkThemeLoader

_style = """
        Tk{
            background: "#565657"; /*background color of the root widget*/
        }

        Label{
            foreground: "#ebebeb";
            background: "#565657";
        }

        Button{
            foreground: "#ebebeb";
            background: "#565657";
        }

        """

root = Tk()

Label(root, text="label").pack()
Button(root, text="Button").pack()

theme = TkThemeLoader(root)
theme.setStylesheet(_style)  # pass as string

root.mainloop()

If you want to load tkss from a file:

  1. save you theme in a file
  2. load it using TkThemeLoader().loadStyleSheet(file_path)

example:

theme.tkss

Tk{
    background: "#565657";
}

Label{
    foreground: "#ebebeb";
    background: "#565657";
}

Button{
    foreground: "#ebebeb";
    background: "#565657";
}

project.py

from tkinter import *
from tkstylesheet import TkThemeLoader

root = Tk()

Label(root, text="label").pack()
Button(root, text="Button").pack()

theme = TkThemeLoader(root)
theme.loadStyleSheet("theme.tkss")  # pass file path

root.mainloop()

Please read further examples on how to switch theme etc, here. Refer stylesheets examples here

Documentation here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tkstylesheet-0.0.1b0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

tkstylesheet-0.0.1b0-py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page