0
In the code below I created a graphical interface with some buttons, but when I click on the buttons they do not call the function. I didn’t find the error, I ask for help.
# Importando a biblioteca tkinter
from tkinter import *
from functools import partial
def abre(j):
if (j==1):
lbr['text'] = 'Clicou no Primeiro'
elif(j==2):
lbr['text'] = 'Clicou no Segundo'
# Criando a janela principal
janela = Tk()
janela.geometry('600x600+150+150')
janela.state('zoomed')
janela.title ('DESENVOLVIMENTO DE SISTEMA COMPLETO II')
# para desabilitar botão state=DISABLED
# Gerando os botôes
rotulo =('Primeiro','Segundo','Terceiro','Quarto','Quinto')
k = 180
j=0
for i in rotulo:
j += 1
bt = Button(janela, command=(abre(j)), width=20, height=2, anchor='center',font=("Helvetica", 12) , text=(i),bg='#696969', fg='#FFA500')
bt.place(x=k,y=2)
k += 200
lbr = Label(janela,text='Teste dos botões')
lbr.place(x=200,y=200)
# Término do sistema.
janela.mainloop()
Hello @José Alves, please test my answer. If you agree please mark as right. If you need help I’m available. Hug!
– Éder Garcia