[Tkinter-discuss] Binding a List to a ScrollBar
Nicco Kunzmann
niccokunzmann at rambler.ru
Thu Jan 16 09:50:40 CET 2014
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 at python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20140116/ff13ac21/attachment.html>
More information about the Tkinter-discuss
mailing list