Skip to content

Commit

Permalink
enable deselecting a mutually exclusive group
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskiehl committed Oct 21, 2017
1 parent 3e59b10 commit 25de9a1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions gooey/gui/widgets/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def __init__(self, parent, title, msg, choices=None):

self.do_layout(parent, title, msg)

self.selected_button = None

def do_layout(self, parent, titles, msgs):
self.panel = wx.Panel(parent)

Expand All @@ -192,13 +194,20 @@ def do_layout(self, parent, titles, msgs):

self.panel.SetSizer(vertical_container)
self.panel.Bind(wx.EVT_SIZE, self.onResize)
self.panel.Bind(wx.EVT_RADIOBUTTON, self.showz)

for button in self.radio_buttons:
button.Bind(wx.EVT_LEFT_DOWN, self.handle_selection)

return self.panel

def showz(self, evt):
print(evt)
for i in self.radio_buttons:
print(i.GetValue())
def handle_selection(self, event):
if event.EventObject.Id == getattr(self.selected_button, 'Id', None):
# if it is already selected, manually deselect it
self.selected_button.SetValue(False)
self.selected_button = None
else:
event.Skip()
self.selected_button = event.EventObject

def onResize(self, evt):
msg = self.help_msgs[0]
Expand Down

0 comments on commit 25de9a1

Please sign in to comment.