Hello Rob, as far as I remember you can only insert text into a Listbox. Maybe you pack Widgets onto a Listbox they appear but it does not make them items. Try this: mylist.insert(END,*c* ) mylist.itemconfigure(END, background = c) If you want to change the background.
Greetings, Nicco Am 16.01.2014 07:06, schrieb Rob Ward: > Hi Folks, > Sorry to be back so soon but I have another challenge. I wanted to > choose some colours for my program and came across a program that > claimed to list the colours in a nifty little Python program. Cute I > thought, I must try that. Quite a few hours later I am stumped. Here > is the code with only the first 26 colours as data - > > from tkinter import * > > COLORS =['snow', 'ghost white', 'white smoke', 'gainsboro', 'floral > white', 'old lace', > 'linen', 'antique white', 'papaya whip', 'blanched almond', > 'bisque', 'peach puff', > 'navajo white', 'lemon chiffon', 'mint cream', 'azure', 'alice > blue', 'lavender', > 'lavender blush', 'misty rose', 'dark slate gray', 'dim gray', > 'slate gray', > 'light slate gray', 'gray', 'light grey'] > > root = Tk() > scrollbar = Scrollbar(root) > scrollbar.pack( side = RIGHT, fill=Y ) > > mylist = Listbox(root, yscrollcommand = scrollbar.set ) > for c in COLORS: > e = Label(mylist, text = c, background = c) > mylist.insert(END,e ) > e.pack(fill=X)#Problem line???? > > mylist.pack( side = LEFT, fill = BOTH ) > scrollbar.config( command = mylist.yview ) > > mainloop() > As you can see I have an interesting line shown as a "Problem > line????". If this line is out I get a list of pairs of number showing > the default 10 lines and the list of numbers is "scrollable". > However if the line is in as shown above, I get a list 26 lines long, > with the lovely colours nicely shown. If I drag the list to a shorter > size, the scroll bar appears but its movement does not link with the > list. It goes up an down nicely but the list stays still. This is > rather inconvenient when trying to view the complete list of colours, > which is 479 high! > > Thanks in anticipation of anyone being able to help me, it will be > very much appreciated. > > Cheers, Rob > > > > > _______________________________________________ > Tkinter-discuss mailing list > Tkinter-discuss@python.org > https://mail.python.org/mailman/listinfo/tkinter-discuss
_______________________________________________ Tkinter-discuss mailing list Tkinter-discuss@python.org https://mail.python.org/mailman/listinfo/tkinter-discuss