1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Python3 Tkinter array + button [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 18, 2025.

  1. Stack

    Stack Membro Participativo

    Hello everyone I have a problem with Tkinter. I have an array with arrays inside and buttons. Logically, it should be that when the buttons are pressed, the ID of a particular button should be displayed in the terminal, and the ID of the last one is displayed. How can I fix this?

    My code:

    import tkinter
    master = tkinter.Tk()

    arr = [[1,"qwe"], [2,"rty"], [3, "uio"]]
    for i in arr:
    tkinter.Button(master, text=i[1], command=lambda: print(i[0])).pack()
    master.mainloop()

    Continue reading...

Compartilhe esta Página