By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

[Tkinter] Listbox only takes one column

P: n/a
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.

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Jul 18 '05 #2

P: n/a
Thank you Peter.


Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.