2
I created this code and intended that when I click on print
, automatically write in Terminal everything you wrote in Text
:
from tkinter import *
janela=Tk()
#cores
branco="white"
preto="black"
cinza="gray"
#confg da janela
janela["bg"]=branco
janela.geometry("500x500+50+50")
#funções
def opa():
print(texto.get())
#objetos da tela
framepri=LabelFrame(janela,bg=preto)
salvar=Button(janela,bg=preto,text="print",fg=branco,command=opa)
texto=Text(janela,bg=branco,fg=preto)
#posições dos objetos
framepri.pack(anchor=NW)
texto.pack(anchor=NW)
salvar.pack(anchor=NW)
#----------------------
janela.mainloop()`
but when compiling, executing, writing something on Text
and tighten in print
, that is the result:
print(texto.get())
TypeError: get() missing 1 required positional argument: 'index1'