[Pythonmac-SIG] Multi-Columns lists with TK?
Anthony M. Ingraldi
A.M.INGRALDI@larc.nasa.gov
Tue, 04 May 1999 22:01:34 -0400
On Tuesday, May 4, 1999, Sean Hummel wrote:
> Is it possible to use TK to make a multi column list?
>
Here's a semi-brief example that shows how to have one scrollbar controlling
two lists. It also shows how to do a simple menubar.
--
from Tkinter import *
import sys
root = Tk()
menuBar = Menu()
root.config(menu=menuBar)
fileMenu = Menu(menuBar)
fileMenu.add_command(label='Quit', command=sys.exit,
accelerator='Command+Q')
menuBar.add_cascade(label='File', menu=fileMenu)
aList = Listbox(root, selectmode=SINGLE)
anotherList = Listbox(root, selectmode=SINGLE)
aScrollbar = Scrollbar(root, orient=VERTICAL)
def scroll_em(*args):
apply(aList.yview, args)
apply(anotherList.yview, args)
aList.config(yscrollcommand=aScrollbar.set)
anotherList.config(yscrollcommand=aScrollbar.set)
aScrollbar.config(command=scroll_em)
aList.pack(side=LEFT, expand=1, fill=BOTH)
anotherList.pack(side=LEFT, expand=1, fill=BOTH)
aScrollbar.pack(side=LEFT, fill=Y)
# add some list items
for i in range(30):
aList.insert(END, 'ITEM' + `i`)
anotherList.insert(END, 'ITEM' + `i`)
root.mainloop()
--
Tony Ingraldi | e-mail: A.M.INGRALDI@LaRC.NASA.GOV
NASA Langley Research Center |
Mail Stop 267 | Phone : (757) 864-3039
Hampton, VA 23681-2199 | Fax : (757) 864-7892