https://github.com/paulledemon/tkstylesheet
stylesheet for Tkinter
https://github.com/paulledemon/tkstylesheet
css stylesheets theme themes tkinter tkss
Last synced: 9 months ago
JSON representation
stylesheet for Tkinter
- Host: GitHub
- URL: https://github.com/paulledemon/tkstylesheet
- Owner: PaulleDemon
- License: mit
- Created: 2021-07-20T13:16:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-04T04:14:57.000Z (almost 2 years ago)
- Last Synced: 2025-09-22T22:56:07.726Z (10 months ago)
- Topics: css, stylesheets, theme, themes, tkinter, tkss
- Language: Python
- Homepage:
- Size: 60.5 KB
- Stars: 16
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Tkinter stylesheet - Tkss
[](https://opensource.org/licenses/MIT)
This library helps you to set style to tkinter default widget using stylesheet without
much work.
**Quick Example:**
```python
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
```python
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](https://github.com/PaulleDemon/tkStyleSheet/tree/master/Examples).
Refer stylesheets examples [here](https://github.com/PaulleDemon/tkStyleSheet/tree/master/Examples/Themes)
Documentation [here](https://github.com/PaulleDemon/tkStyleSheet/blob/master/Documentation.md)