[Tutor] Listbox insertion
Alan Gauld
alan.gauld at blueyonder.co.uk
Thu Apr 29 17:08:27 EDT 2004
> How would I go about inserting text from a file into a listbox. I
was
> thinking that maybe a listbox is not what I am wanting. See, I have
a file
> that I have created and it inserts a file name from an
askopenfilename
> dialog when selected. I then want to put the information into that
listbox
> (or maybe a label?).
The description isn't specific enough to answer, but it sounds like
maybe you want the listbox to hold a list of filenames and a Text
widget to hold the contents of the highlighted filename?
The Tkinter Text widget is a powerful widget capable of displaying
a lot more than text, it can also hold images etc.
> I am not finding much documentation about inserting
> information into a list box.
A Listbox takes a data item and inserts it at the specified
position. The easiest being END:
L = Listbox(root, width=20)
L.pack()
for item in [1,2,3,4,5]
L.insert(END, item) # appends item at the end
L.insert(0, 0) # inserts at front
That's it... not too hard is it?
Alan G.
More information about the Tutor
mailing list