Skip to content

Commit

Permalink
README Update
Browse files Browse the repository at this point in the history
Comes with the new Tk based demo.
  • Loading branch information
definite-d committed Aug 14, 2023
1 parent 61b2369 commit 45ddbfc
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,57 +9,69 @@
![License](https://img.shields.io/pypi/l/psg-reskinner.svg?style=flat&version=latest)

````shell
pip install --upgrade PSG-Reskinner
pip install PSG-Reskinner
````

<p align="center">
<img src="https://github.com/definite-d/psg_reskinner/blob/main/res/demo.gif">
</p>

## What's Reskinner?

Reskinner is a Python 3 plugin for PySimpleGUI's Tkinter port which enables changing the theme of a PySimpleGUI window on the fly without the need for re-instantiating the window.

Please consider starring the project if you find it useful.

## Example Usage (Demo)

```python
# Reskinner Version 2

from psg_reskinner import reskin, animated_reskin, __version__
from PySimpleGUI import Window, Text, Button, Push, Titlebar, theme_list, theme, LOOK_AND_FEEL_TABLE, TIMEOUT_KEY
# Reskinner Version 2.3.13
from psg_reskinner import animated_reskin, __version__
from PySimpleGUI import Window, Text, Button, Push, Titlebar, theme, theme_list, LOOK_AND_FEEL_TABLE
from random import choice as rc

rmenu = ['', ['Hi', 'There']]
right_click_menu = ['', [['Hi', ['Next Level', ['Deeper Level', ['a', 'b', 'c']], 'Hoho']], 'There']]

window_layout = [
[Titlebar('Reskinner Demo')],
[Text('Hello!', font=('Helvetica', 20))],
[Text('You are currently running Reskinner instead of importing it.')],
[Text('The theme of this window changes every 3 seconds.')],
[Text('The theme of this window changes every 2 seconds.')],
[Text('Changing to:')],
[Button('DarkBlue3', k='ctheme', font=('Helvetica', 16), right_click_menu=rmenu)],
[Button('DarkBlue3', k='current_theme', font=('Helvetica', 16), right_click_menu=right_click_menu)],
[Text(f'Reskinner v{__version__}', font=('Helvetica', 8), pad=(0, 0)), Push()],
]

window = Window('Reskinner Demo', window_layout, element_justification='center')
window = Window('Reskinner Demo', window_layout, element_justification='center', keep_on_top=True)

def _reskin_job():
themes = theme_list()
themes.remove(theme())
new = rc(themes)
window['current_theme'].update(new)
animated_reskin(
window=window,
new_theme=new,
theme_function=theme,
lf_table=LOOK_AND_FEEL_TABLE,
)
window.TKroot.after(2000, _reskin_job)

started = False

while True:

e, v = window.Read(timeout=2000)
e, v = window.read(timeout=2000)

if e in (None, 'Exit'):
window.Close()
break

elif e == TIMEOUT_KEY:
new = rc(theme_list())
window['ctheme'].update(new)
animated_reskin(window=window,
new_theme=new,
theme_function=theme,
lf_table=LOOK_AND_FEEL_TABLE,)
```
if not started:
_reskin_job()
started = True

```

## How does it work?

Expand Down

0 comments on commit 45ddbfc

Please sign in to comment.