Browse Source

Set default state in a CheckBox

pull/116/head
Joaquin Santos 9 years ago
parent
commit
0d94e19c81
1 changed files with 3 additions and 1 deletions
  1. 4
      gooey/gui/widgets/components.py

4
gooey/gui/widgets/components.py

@ -112,6 +112,7 @@ class CheckBox(BaseGuiComponent):
self.widget = None self.widget = None
# data # data
self.option_strings = data['commands'][0] self.option_strings = data['commands'][0]
self.default_value = bool(data['default'])
def build(self, parent): def build(self, parent):
return self.do_layout(parent) return self.do_layout(parent)
@ -120,6 +121,7 @@ class CheckBox(BaseGuiComponent):
self.panel = wx.Panel(parent) self.panel = wx.Panel(parent)
self.widget = wx.CheckBox(self.panel) self.widget = wx.CheckBox(self.panel)
self.widget.SetValue(self.default_value)
self.title = self.createTitle(self.panel) self.title = self.createTitle(self.panel)
self.help_msg = self.createHelpMsgWidget(self.panel) self.help_msg = self.createHelpMsgWidget(self.panel)
self.help_msg.SetMinSize((0, -1)) self.help_msg.SetMinSize((0, -1))
@ -218,7 +220,7 @@ class RadioGroup(object):
def GetValue(self): def GetValue(self):
vals = [button.GetValue() for button in self.radio_buttons] vals = [button.GetValue() for button in self.radio_buttons]
try: try:
return self.option_stings[vals.index(True)][0]
return self.option_strings[vals.index(True)][0]
except: except:
return '' return ''

Loading…
Cancel
Save