Skip to content

Commit

Permalink
Merge pull request #73 from slootsky/develop
Browse files Browse the repository at this point in the history
allow for no preselect on choicebox and multchoicebox
  • Loading branch information
robertlugg committed Jun 4, 2015
2 parents d53bf30 + 91d8a1b commit 66a0226
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions easygui/boxes/choice_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ def choicebox(msg="Pick an item", title="", choices=[], preselect=0,
:param list choices: a list or tuple of the choices to be displayed
:return: List containing choice selected or None if cancelled
"""
mb = ChoiceBox(msg, title, choices, preselect=preselect,
multiple_select=False,
callback=callback)
if run:
mb = ChoiceBox(msg, title, choices, preselect=preselect,
multiple_select=False,
callback=callback)
reply = mb.run()
return reply
else:
mb = ChoiceBox(msg, title, choices, preselect=preselect,
multiple_select=False,
callback=callback)
return mb


Expand All @@ -46,16 +43,13 @@ def multchoicebox(msg="Pick an item", title="", choices=[],
""" Same as choicebox, but the user can select many items.
"""
mb = ChoiceBox(msg, title, choices, preselect=preselect,
multiple_select=True,
callback=callback)
if run:
mb = ChoiceBox(msg, title, choices, preselect=preselect,
multiple_select=True,
callback=callback)
reply = mb.run()
return reply
else:
mb = ChoiceBox(msg, title, choices, preselect=preselect,
multiple_select=True,
callback=callback)
return mb


Expand Down Expand Up @@ -239,8 +233,9 @@ def get_pos(self):
global_state.window_position = '+' + geom.split('+', 1)[1]

def preselect_choice(self, preselect):
self.choiceboxWidget.select_set(preselect)
self.choiceboxWidget.activate(preselect)
if preselect <> None:
self.choiceboxWidget.select_set(preselect)
self.choiceboxWidget.activate(preselect)

def get_choices(self):
choices_index = self.choiceboxWidget.curselection()
Expand Down

0 comments on commit 66a0226

Please sign in to comment.