1
def text():
    print('Hello, world!!')


from tkinter import *
janela = Tk()
janela.title('Test')
janela.geometry('800x800')
botao = Button(janela,text='Clique aqui',command=text)
botao.grid(column=0,row=0)
janela.mainloop()

That's the code. How can I print the "Hello, world!" as a Label on the Tk or something like this?

Well, I just want the text appears at the Tk.

Gabiloko
  • 21
  • 2

1 Answers1

1

This should work:

from tkinter import *
janela = Tk()
janela.title('Test')
janela.geometry('800x800')

def text():
    label = Label(text="Hello World!")
    label.grid(column=0, row=1)
    

botao = Button(janela,text='Clique aqui',command=text)
botao.grid(column=0,row=0)
janela.mainloop()

kool
  • 86
  • 7