I am trying to make a gui application in Python using tKinter to display an arbitrary amount of phone numbers in buttons, and for clicking that button to display that contact's text messages.
What I have is:
from tkinter import *
def displayTexts(name, list_of_Contacts):
cont = findContact(name, list_of_Contacts)
for text in cont.listOfTexts:
(Message(right_frame, text=text.body)).pack(side=TOP)
for contact in list_of_Contacts:
(Button(left_frame, text=contact.name, command= lambda: displayTexts(contact.name, list_of_Contacts))).pack()
However, clicking any button results in only the last text from the last contact button created being displayed. A similar issue appeared already, and although he says he solved his issue, I can't seem to understand how or why.
I tried adapting his code to fit mine but I get an error saying Nonetype has no listofTexts attribute.
buttons = dict()
for k in list_of_Contacts:
buttons[k.name] = Button(left_frame, text=k.name, command= lambda a=k.name: displayTexts(buttons[a], list_of_Contacts)).pack()
One thing I can't figure out is how to get the text of the button from button[a], and another is how this list/dictionary solution is supposed to be implemented.
Thank you
edit: I don't see how Checkboxes is a duplicate, in fact I don't understand his problem either. The answer sounds like it could apply here but I haven't the faintest how.
edit2: That solution didn't work, its still giving findContant a noneType for the name string.