Skip to content

Commit

Permalink
Version 2.0 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende authored Sep 11, 2022
1 parent 3b80890 commit de635b2
Show file tree
Hide file tree
Showing 370 changed files with 8,687 additions and 1,190 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/generate_spritesheet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

name: Generate sprite sheet

on:
push:
paths:
- 'src/dark/**.png'
- 'src/light/**.png'

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
cd src
npm install
- name: Generate sprite sheet image and sprite map
run: |
cd src
node spritesheet_generator.js
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Automation: Update sprite sheets"
file_pattern: theme/*.*
32 changes: 32 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Upload to Pypi

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: "3.9"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Prepare package
run: |
mkdir sv_ttk
cp -r sv_ttk.py sv.tcl theme sv_ttk
mv sv_ttk/sv_ttk.py sv_ttk/__init__.py
- name: Build and publish to Pypi
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Dependency directories
node_modules/

# Build directories
sv_ttk/
build/
dist/
sdist/
wheels/
*.egg-info/
71 changes: 12 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rdbende/Sun-Valley-ttk-theme/master/assets/dark.png">
<img alt="Cover image" src="https://raw.githubusercontent.com/rdbende/Sun-Valley-ttk-theme/master/assets/light.png">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/rdbende/Sun-Valley-ttk-theme/master/assets/hero_dark.png">
<img alt="Cover image" src="https://raw.githubusercontent.com/rdbende/Sun-Valley-ttk-theme/master/assets/hero_light.png">
</picture>

## Installation [![image](https://static.pepy.tech/badge/sv-ttk)](https://pypi.org/project/sv-ttk)
Expand All @@ -12,75 +12,28 @@ pip install sv-ttk


### Usage
For detailed documentation, see the [wiki page](https://github.com/rdbende/Sun-Valley-ttk-theme/wiki/sv_ttk-docs)

```python
import tkinter as tk
import tkinter
from tkinter import ttk

import sv_ttk

root = tk.Tk()

sv_ttk.set_theme("light") # Set light theme
sv_ttk.set_theme("dark") # Set dark theme

sv_ttk.use_light_theme() # Set light theme
sv_ttk.use_dark_theme() # Set dark theme
button = ttk.Button(root, text="Click me!")
button.pack()

sv_ttk.toggle_theme() # Toggle between dark and light theme

print(sv_ttk.get_theme()) # Get what theme the app uses (either 'light' or 'dark')
# This where the magic happens
sv_ttk.set_theme("dark")

root.mainloop()
```

## Usage with Tcl/Tk
To make setting the theme and the right colours as easy as possible, there is a separate script that handles all this.
This way whether you want to use a dark or light theme, you need to import just a single file, and the colors will be
configured even for non-ttk widgets for a consistent look.

```tcl
source sun-valley.tcl
set_theme light ;# Set light theme
# or
set_theme dark ;# Set dark theme
```

### Switching themes
Normally changing between themes isn't that easy, because then the colors doesn't get configured correctly. See this [SO question](https://stackoverflow.com/questions/66576662/how-to-switch-between-dark-and-light-ttk-theme).
However, with my current solution, you can change theme at any time, without any color issues.

```tcl
package require Tk 8.6
source "sun-valley.tcl"
set_theme light
# Pack a big frame so, it behaves like the window background
ttk::frame .big_frame
pack .big_frame -fill both -expand 1
proc changeTheme {} {
# NOTE: The theme's real name is sun-valley-<mode>
if {[ttk::style theme use] == "sun-valley-dark"} {
# Set light theme
set_theme light
} else {
# Set dark theme
set_theme dark
}
}
ttk::button .big_frame.button -text "Change theme!" -command changeTheme
pack .big_frame.button
```

## 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!](https://github.com/rdbende/Sun-Valley-ttk-theme/tree/gif-based/) (hasn't been updated for a while)
- When you change the theme, and your app has a `treeview`, the window resizes. This is a quite strange bug that applies to other ttk themes too.

## Examples
I made a separate repo for the examples: [Sun-Valley-ttk-examples](https://github.com/rdbende/Sun-Valley-ttk-examples).
Be sure to **star** and **watch** it because I might make some more examples, with awesome tips and tricks!
## Known bugs and limitations
- Tkinter (Tk) isn't really good at displaying `png` images, so the window can be quite laggy when resizing, especially on Windows.

## What's next?
Check out my other ttk themes!
Expand Down
Binary file added assets/cover_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cover_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/dark.png
Binary file not shown.
Binary file added assets/hero_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/hero_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/light.png
Binary file not shown.
Binary file added assets/social.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from setuptools import setup

with open("README.md", "r") as file:
long_description = file.read()


setup(
name="sv_ttk",
version="2.0",
license="MIT",
author="rdbende",
author_email="[email protected]",
url="https://github.com/rdbende/Sun-Valley-ttk-theme",
project_urls={
"Source": "https://github.com/rdbende/Sun-Valley-ttk-theme",
"Tracker": "https://github.com/rdbende/Sun-Valley-ttk-theme/issues",
},
description="A gorgeous theme for Tkinter that looks like Windows 11",
long_description=long_description,
long_description_content_type="text/markdown",
packages=["sv_ttk"],
package_data={"sv_ttk": ["sv.tcl", "theme/*"]},
python_requires=">=3.4",
classifiers=[
"Intended Audience :: Developers",
"Topic :: Software Development :: User Interfaces",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Tcl",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
keywords=[
"dark-theme",
"sun-valley",
"tcl",
"tcl/tk",
"theme",
"theme",
"tile",
"tk",
"tkinter",
"ttk",
"windows-11",
"winui",
],
)
16 changes: 16 additions & 0 deletions src/dark/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Source images for Sun Valley dark theme

This directory contains the source images of `spritesheet_dark.png` (which is generated by `spritesheet_generator.js`), and the SVG source file as well.

## How to generate the png files?

1. Open `dark.svg` with [Inkscape](https://inkscape.org/)
2. Press Ctrl+Shift+E
3. Select every element that _doesn't_ have transparency and click on the `Selection` tab in the export box
4. Click `Batch export <blah> selected objects`
5. Click on `Advanced`
6. Set the bit depth to `RGB_8` and the antialiasing to `CAIRO_ANTIALIAS_GOOD (default)`
7. Click `Export`
8. Now select every item that _has_ transparency
9. Set the bit depth to `RGBA_8` and the antialiasing to `CAIRO_ANTIALIAS_BEST`
10. Click `Export`
Binary file added src/dark/button-accent-dis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-accent-focus-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-accent-focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-accent-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-accent-pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-accent-rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-dis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-focus-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/button-rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/check-dis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/check-focus-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/check-focus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/check-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/check-pressed.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/dark/check-rest.png
Binary file added src/dark/check-tri-dis.png
Binary file added src/dark/check-tri-focus-hover.png
Binary file added src/dark/check-tri-focus.png
Binary file added src/dark/check-tri-hover.png
Binary file added src/dark/check-tri-pressed.png
Binary file added src/dark/check-tri-rest.png
Binary file added src/dark/check-unsel-dis.png
Binary file added src/dark/check-unsel-focus-hover.png
Binary file added src/dark/check-unsel-focus.png
Binary file added src/dark/check-unsel-hover.png
Binary file added src/dark/check-unsel-pressed.png
Binary file added src/dark/check-unsel-rest.png
Loading

0 comments on commit de635b2

Please sign in to comment.