[Tkinter] Listbox only takes one column

  • Thread starter Nicolas Favre-Félix
  • Start date
N

Nicolas Favre-Félix

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)


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.
 
P

Peter Otten

Nicolas said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top