I'm new to Python, and programming in general. What I'm trying to do here is to load a list of accounts from a file on my harddrive into a string of Buttons in Tkinter, and when I press one of the Buttons, which has one of my account name, it will load that account into a new window. But I don't understand how to code the proccess that would tell the program what account is selected. Any help with this would be very appreciated. Thanks in advance.
from Tkinter import * import shelve from tkMessageBox import showerror shelvename = shelve.open('class-shelve2') cat = (' Name ', ' Account # ', ' Amount Due ', ' Date Due ') def NameFields(top): name1 = Label(None, text=cat[0], relief=RIDGE, width=20, fg='blue', bg='white', font=('bold',15)) name2 = Label(None, text=cat[1], relief=RIDGE, width=15, fg='blue', bg='white', font=('bold',15)) name3 = Label(None, text=cat[2], relief=RIDGE, width=15, fg='blue', bg='white', font=('bold',15)) name4 = Label(None, text=cat[3], relief=RIDGE, width=15, fg='blue', bg='white', font=('bold',15)) name1.grid(row=0, column=0, sticky=NSEW) name2.grid(row=0, column=1, sticky=NSEW) name3.grid(row=0, column=2, sticky=NSEW) name4.grid(row=0, column=3, sticky=NSEW) top.columnconfigure(0, weight=1) top.columnconfigure(1, weight=1) top.columnconfigure(2, weight=1) top.columnconfigure(3, weight=1) def DisplayBills(top): c=0 for bill in shelvename: bill1 = Button(None, text= shelvename[bill].name, font=('bold',10), command=fetchRecord) bill2 = Label(None, text= shelvename[bill].account, relief=RIDGE, font=('bold',10)) bill3 = Label(None, text= shelvename[bill].paymentDue, relief=RIDGE, font=('bold',10), fg='red') bill4 = Label(None, text= shelvename[bill].dateDue, relief=RIDGE, font=('bold',10)) bill1.grid(row=c, column=0, sticky=NSEW) bill2.grid(row=c,column=1, sticky=NSEW) bill3.grid(row=c,column=2, sticky=NSEW) bill4.grid(row=c,column=3, sticky=NSEW) c = c + 1 def fetchRecord(): top = Tk() DisplayBills(top), NameFields(top) mainloop() -- http://mail.python.org/mailman/listinfo/python-list