Search code examples
pythontkinter

How to pack two buttons of the same kind?


I'm working on a simple contact list application, and I want that Tkinter places a button for every contact made. This is the code I've made:

from tkinter import *
main = Tk()
main.title("Contacts +")
main.geometry('420x300')
main.resizable(0,0)
contact_button = Button(text="NameExample")

contact_button.pack()
contact_button.pack()

main.mainloop()

I expected that Tkinter displays two buttons of the same kind, but he instead just shows one button. Is there a way to resolve this problem?


Solution

  • I fixed the issue using clickable listboxes:

    contactlist = Listbox(main,width=30)
    contactlist.pack()
    for names in namelist: contactlist.insert(END, names)