Listbox and Hashtable troubles

Diez B. Roggisch nospam-deets at web.de
Thu Feb 19 18:22:09 CET 2004


First: Don't use HTML when posting!!! 

Second: What gui-toolkit do you use? Maybe its possible to associate a
key/value pair to the listbox, where only the value is displayed, but that
depends on your toolkit.

Whatever toolkit it is, usually you get the index of the entry the user
selected - now if you have a dict, you somehow have to enumerate the values
you get. This order you can use:

hm = {1 : "one", 2 : "two"}

items = hm.items() # yields (1, "one"), (2, "two")

for key, value in items:
  lb.add(value)

index = lb.get_user_pressed_index()
key = items[index][0]
-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list