From 29e8fc0270d5b662925959d274045fad0f44e813 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 13 Sep 2020 16:14:54 -0700 Subject: [PATCH] fixes weird bug in RadioGroup where child interactions could cause radiobuttons to lose their selection --- gooey/gui/components/widgets/radio_group.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gooey/gui/components/widgets/radio_group.py b/gooey/gui/components/widgets/radio_group.py index 70d03be..2c52172 100644 --- a/gooey/gui/components/widgets/radio_group.py +++ b/gooey/gui/components/widgets/radio_group.py @@ -103,13 +103,23 @@ class RadioGroup(BaseWidget): Conditionally disabled/enables form fields based on the current section in the radio group """ - for button, widget in zip(self.radioButtons, self.widgets): + # for reasons I have been completely unable to figure out + # or understand, IFF you've interacted with one of the radio Buttons's + # child components, then the act of disabling that component will + # reset the state of the radioButtons thus causing it to forget + # what should be selected. So, that is why we're collected the initial + # state of all the buttons and resetting each button's state as we go. + # it's wonky as hell + states = [x.GetValue() for x in self.radioButtons] + for button, selected, widget in zip(self.radioButtons, states, self.widgets): if isinstance(widget, CheckBox): widget.hideInput() - if not button.GetValue(): # not checked + if not selected: # not checked widget.Disable() else: widget.Enable() + button.SetValue(selected) + def handleImplicitCheck(self): """