[Tkinter-discuss] Setting the items of a listbox with new technique in TK 8.3

Sunburned Surveyor sunburned.surveyor at gmail.com
Mon Jan 25 02:53:05 CET 2010


I'm new to Tkinter programming, and I'm fairly new to Python. (I come
from a Java programming background.) I've been trying to put together
my first Tk GUI with Tkinter. I've been reading some of the
documentation at tkdocs.com. The documentation at tkdocs.com mentions
using the list variable option made available in Tk 8.3 to set the
items of a list box, instead of using the old insert method. I can
successfully add items to the listbox in Tkinter using the old insert
method, but I'm having trouble with the new method.

I create a list of strings stored in a variable, and then pass the
name of this variable as an option when creating the listbox as
follows:

featureTypesList = ("Roads", "Field Observations", "Railroads", "Work Areas")
featureTypeListbox = Listbox(mainFrame, listvariable=featureTypesList, height=3)

However, when I display my GUI on the screen, none of the values in my
list show up in my listbox. Is there another step that I am missing?
Do I need to do something else to "bind" the values in my list to the
listbox?

I appreciate any suggestions.

I'm using Python 3.1 with the built-in Tkinter and ttk modules on
Microsoft Windows XP.

Here is the link for the web page at tkdocs.com that I have been
reading to learn about the use of the listbox widget in Tkinter:

http://www.tkdocs.com/tutorial/morewidgets.html#listbox

The Sunburned Surveyor


More information about the Tkinter-discuss mailing list