Skip to content

Commit ccf73a8

Browse files
committed
change default parameter: use_ttk_button=True
1 parent ae504d1 commit ccf73a8

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

TkEasyGUI/widgets.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,7 @@ class Button(Element):
23372337
23382338
**Example**
23392339
The program below changes the button's label to "Pushed" when the button is pressed.
2340+
23402341
```python
23412342
import TkEasyGUI as eg
23422343
button:eg.Button = eg.Button("Push me")
@@ -2346,6 +2347,12 @@ class Button(Element):
23462347
button.set_text("Pushed")
23472348
break
23482349
```
2350+
2351+
`use_ttk_buttons` parameter is set to `True` by default, which makes buttons look more modern.
2352+
However, on macOS, the default `ttk.Button` has a gray background and does not support changing the background color.
2353+
If you want to change the button color on macOS, set `use_ttk_buttons=False` to use `tk.Button` instead.
2354+
Also, when `use_ttk_buttons=True`, explicit button height settings are ignored due to a `ttk` limitation.
2355+
If you need to control button height, set `use_ttk_buttons=False`.
23492356
"""
23502357

23512358
# pylint: disable=too-many-arguments, too-many-locals
@@ -2363,23 +2370,21 @@ def __init__(
23632370
font: Optional[FontType] = None, # font
23642371
color: Optional[str] = None, # text color
23652372
text_color: Optional[str] = None, # same as color
2366-
background_color: Optional[
2367-
str
2368-
] = None, # background color (not supported on macOS)
2373+
background_color: Optional[str] = None, # background color (not supported on macOS)
23692374
# pack props
23702375
expand_x: bool = False,
23712376
expand_y: bool = False,
23722377
pad: Optional[PadType] = None,
23732378
# other
2374-
use_ttk_buttons: Optional[bool] = None,
2379+
use_ttk_buttons: bool = True,
23752380
metadata: Optional[dict[str, Any]] = None,
23762381
**kw,
23772382
) -> None:
23782383
"""Create a Button element."""
23792384
key = button_text if (key is None) or (key == "") else key
23802385
super().__init__("Button", "TButton", key, False, metadata, **kw)
23812386
# On Windows, ttk buttons look more modern by default.
2382-
self.use_ttk = utils.is_win() if use_ttk_buttons is None else use_ttk_buttons
2387+
self.use_ttk = use_ttk_buttons
23832388
self.disabled = False
23842389
if disabled is not None:
23852390
self.props["disabled"] = self.disabled = disabled

docs/theme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ window.read()
6969
window.close()
7070
```
7171

72+
Note:
73+
- If you set `use_ttk_buttons=True`, explicit button height settings are ignored.
74+
- This is a limitation of `ttk`.
75+
- If you need to control button height, use `use_ttk_buttons=False`.
76+
77+
78+
79+
7280
## How to customize defaults
7381

7482
### Global theme default

0 commit comments

Comments
 (0)