|
| 1 | +# TkEasyGUI Theme Guide |
| 2 | + |
| 3 | +This document explains how to use themes and how to change theme-related defaults in TkEasyGUI. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +TkEasyGUI uses `ttk` themes for modern widget rendering. |
| 8 | +You can switch themes at runtime using `set_theme()` or `theme()`. |
| 9 | + |
| 10 | +Default theme by platform: |
| 11 | + |
| 12 | +- macOS: `aqua` |
| 13 | +- Windows: `vista` |
| 14 | +- Linux/others: `clam` |
| 15 | + |
| 16 | +## Basic theme usage |
| 17 | + |
| 18 | +### Change theme with `set_theme` |
| 19 | + |
| 20 | +```python |
| 21 | +import TkEasyGUI as eg |
| 22 | + |
| 23 | +eg.set_theme("clam") |
| 24 | +window = eg.Window("Theme sample", [[eg.Button("OK", use_ttk_buttons=True)]]) |
| 25 | +window.read() |
| 26 | +window.close() |
| 27 | +``` |
| 28 | + |
| 29 | +### Alias: `theme` |
| 30 | + |
| 31 | +`theme()` is an alias of `set_theme()`. |
| 32 | + |
| 33 | +```python |
| 34 | +import TkEasyGUI as eg |
| 35 | + |
| 36 | +eg.theme("default") |
| 37 | +``` |
| 38 | + |
| 39 | +## List available themes |
| 40 | + |
| 41 | +Use `get_tnemes()` to inspect themes available in your current Tk runtime. |
| 42 | + |
| 43 | +```python |
| 44 | +import TkEasyGUI as eg |
| 45 | + |
| 46 | +print(eg.get_tnemes()) |
| 47 | +``` |
| 48 | + |
| 49 | +Note: |
| 50 | +- Function name is `get_tnemes()` in current API. |
| 51 | + |
| 52 | +## Change button style behavior |
| 53 | + |
| 54 | +`Button` can render with `ttk.Button` (modern) or `tk.Button` (classic). |
| 55 | + |
| 56 | +- `use_ttk_buttons=True`: use `ttk.Button` |
| 57 | +- `use_ttk_buttons=False`: use `tk.Button` |
| 58 | +- `use_ttk_buttons=None` (default): Windows uses `ttk`, other OS keep previous default behavior |
| 59 | + |
| 60 | +```python |
| 61 | +import TkEasyGUI as eg |
| 62 | + |
| 63 | +layout = [ |
| 64 | + [eg.Button("Modern", use_ttk_buttons=True)], |
| 65 | + [eg.Button("Classic", use_ttk_buttons=False)], |
| 66 | +] |
| 67 | +window = eg.Window("Buttons", layout) |
| 68 | +window.read() |
| 69 | +window.close() |
| 70 | +``` |
| 71 | + |
| 72 | +## How to customize defaults |
| 73 | + |
| 74 | +### Global theme default |
| 75 | + |
| 76 | +If you want to change the default theme for your app, call `set_theme()` before creating windows. |
| 77 | + |
| 78 | +```python |
| 79 | +import TkEasyGUI as eg |
| 80 | + |
| 81 | +eg.set_theme("winnative") |
| 82 | +``` |
| 83 | + |
| 84 | +### Revert to old Windows look |
| 85 | + |
| 86 | +If you want behavior close to older Windows appearance: |
| 87 | + |
| 88 | +```python |
| 89 | +import TkEasyGUI as eg |
| 90 | + |
| 91 | +eg.set_theme("vista") |
| 92 | +layout = [[eg.Button("OK", use_ttk_buttons=False)]] |
| 93 | +window = eg.Window("Legacy look", layout) |
| 94 | +window.read() |
| 95 | +window.close() |
| 96 | +``` |
| 97 | + |
| 98 | +## Recommended test scripts |
| 99 | + |
| 100 | +After changing theme defaults, validate with: |
| 101 | + |
| 102 | +```bash |
| 103 | +python tests/file_viewer.py |
| 104 | +python tests/theme/ttk_button.py |
| 105 | +python tests/ui_test.py |
| 106 | +python tests/many_buttons.py |
| 107 | +``` |
0 commit comments