[Tkinter] Listbox only takes one column
Peter Otten
__peter__ at web.de
Mon Oct 27 14:23:53 EST 2003
Nicolas Favre-Félix wrote:
> Hello,
>
> I have a little problem using Tkinter:
> I'd like to make a interface with 3 labels on the left, facing with 3
> Entry on the right, a button below Entrys, and a Listbox under all. I
> could place the Labels and Entrys, but the Listbox is just in column 0,
> and I want it to take all the width (column 0 + column 1)
>
> here is the code:
> #########################
> from Tkinter import *
>
> root=Tk()
>
> Label(root, text="Artist :").grid(row=0, column=0)
> Label(root, text="Title :").grid(row=1, column=0)
> Label(root, text="Album :").grid(row=2, column=0)
> Label(root, text="Results :").grid(row=4, column=0)
> results = Listbox(root,selectmode=SINGLE)
results.grid(row=5, column=0, columnspan=2)
> artist = Entry(root)
> title = Entry(root)
> album = Entry(root)
>
> artist.grid(row=0, column=1)
> title.grid(row=1, column=1)
> album.grid(row=2, column=1)
> but= Button(root, text="Find")
> but.grid(row=3, column=1)
>
> root.mainloop()
>
> ###############################
>
> How can I do?
>
> Thank you.
Just modify results.grid() as shown above. There is also a similar rowspan
option available, just in case...
Peter
More information about the Python-list
mailing list