Skip to content

Commit a2e5dcd

Browse files
committed
MultiStateButton default names now handle Enum states properly
1 parent 5e73ca3 commit a2e5dcd

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

custom_gui_elements.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from enum import Enum
12
from functools import cached_property
23
from typing import TypeVar, Generic, Any
34
import PySimpleGUI as sg
@@ -40,7 +41,7 @@ def apply_default_names(self):
4041
for state in self.states:
4142
# default param set + 2-level copy
4243
self.options[state] = dict(
43-
button_text=state,
44+
button_text=state if not isinstance(state, Enum) else state.name,
4445
) | self.options[state]
4546

4647
@cached_property

gui.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,13 @@ def build_layout(self):
9494
self.look_for_title_button = MultiStateButton({
9595
LookForTitle.CURRENT: dict(
9696
tooltip="Use title from current window",
97-
button_text="CURRENT"
9897
),
9998
LookForTitle.ROOT: dict(
10099
tooltip="Use title from main (root) window",
101-
button_text="ROOT"
102100
),
103101
LookForTitle.ANY: dict(
104102
tooltip="Use any title from current "
105103
"to root window",
106-
button_text="ANY"
107104
)
108105
},
109106
self.ID.BUTTON_LOOK_FOR_TITLE,

0 commit comments

Comments
 (0)