Tkinter: using a Listbox

Ebba Cecilia Ovesdotter Alm ebbaalm at uiuc.edu
Fri Jan 7 22:00:54 CET 2005


Hello,

I'm learning how to use the Tkinter module. I would like to
use an element similar to a drop-down form,
where the user can select one option out of many. I thought
that a Listbox item could do just this. The following extract
from my code (with the listbox part basically mirroring
http://effbot.org/books/tkinterbook/listbox.htm),
does, however, not create a visable Listbox.  Am I
interpreting the Listbox incorrectly? Ideas or suggestions are
appreciated.

#Frame & label for the listbox
self.selectFrame = Frame(self.root)
self.selectFrame.pack(side=TOP, fill=X, padx=10)
Label(self.selectFrame, text='Primary choice').pack(side=LEFT)
#Listbox
self.listbox = Listbox(self.selectFrame)
self.listbox.insert(END, "a list entry")
for item in ["A","B","C"]:
      self.listbox.insert(END, item)

Thanks,
Cecilia



More information about the Python-list mailing list