Skip to content

Instantly share code, notes, and snippets.

@sycobuny
Created January 30, 2012 01:39
Show Gist options
  • Save sycobuny/1701849 to your computer and use it in GitHub Desktop.
Save sycobuny/1701849 to your computer and use it in GitHub Desktop.
Get the selection of a wx.ComboBox in python
# line 37 in llm/view/dialog/library/abstract.py
self.type = wx.ComboBox(panel,
-1,
choices=["CD/DVD/Blu-Ray", "Book/Magazine"],
style=wx.CB_READONLY)
sbs.Add(self.build_line(wx.StaticText(panel, -1, "Type:"), self.type))
# new line 51 in llm/view/dialog/library/abstract.py
choices_d = ['None']
choices_i = [None]
for data in patron_data:
dd = "%s %s (%d)" % (data["first_name"],
data["last_name"],
data["id"])
choices_d.append(dd)
choices_i.append(data["id"])
self.id_map = choices_i
# somewhere else in that file
def get_selected_cob_id(self):
sel = self.checked_out_by.GetCurrentSelection()
return self.id_map[sel]
# at line 113 in llm/controller.py
item_data = {"name" : self.add_lib_item_dlg.name.GetValue(),
"author_first" : self.add_lib_item_dlg.author_first_name.GetValue(),
"author_last" : self.add_lib_item_dlg.author_last_name.GetValue(),
"desc" : self.add_lib_item_dlg.desc.GetValue(),
"type" : self.add_lib_item_dlg.type.GetValue(),
"cob" : self.add_lib_item_dlg.get_selected_cob_id(),
"id" : 0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment