Skip to content

Commit

Permalink
eg.Radio のイベントが常に最初の要素になってしまうのを修正 #92
Browse files Browse the repository at this point in the history
  • Loading branch information
kujirahand committed Dec 3, 2024
1 parent 06fc144 commit e81b281
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion TkEasyGUI/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1977,10 +1977,22 @@ def __init__(
}, "system")

def create(self, win: Window, parent: tk.Widget) -> tk.Widget:
# post change event
def post_change_event(*args):
selected_key: str = self.key
values = win.get_values()
for k in values.keys():
if values[k] is True:
selected_key = k
values['event'] = args
values['event_type'] = "change"
win.post_event(selected_key, values)
# create radio group
if self.group_id not in win.radio_group_dict:
win.radio_group_dict[self.group_id] = [tk.IntVar(value=0), 1]
win.radio_group_dict[self.group_id][0].trace_add("write", lambda *args: self.disptach_event({"event_type": "change", "event": args}))
win.radio_group_dict[self.group_id][0].trace_add(
"write", lambda *args: post_change_event(*args)
)
else:
win.radio_group_dict[self.group_id][1] += 1
self.value = win.radio_group_dict[self.group_id][1]
Expand Down

0 comments on commit e81b281

Please sign in to comment.