Python 3.x Show data typed in an Entry in a Label only after pressing a button

1

I wanted to know the following;
In my program there are:
Entry1 - > where the user types some information
btn1 - > where it confirms the name and the previously entered data is displayed in the console

asked by anonymous 10.07.2017 / 06:09

2 answers

0

I have. Just apply in def:

def pegar_nome():
    content = var.get()
    print(content)
    lbl2.config(text=content)

lbl2.config (text = content)

and then change

lbl2 = Label(janela, text="")
    
10.07.2017 / 06:22
0

Minimally changing, what you need to do is change this part:

# Nome do pet digitado na tela
lbl2 = Label(janela, text="")
lbl2.pack(anchor=NW)

Note that if you remove the textvariable part, the text will appear only after the button is pressed. And a few minor changes to the function you set, just add something similar to this code after print:

lbl2.config(text=content)
    
21.10.2017 / 06:59