3
I am new to programming and python. I would like to insert a definition a box information that was created in another definition. How is that possible? According to the code, which is attached, the program gives error. Thank you
import tkinter as tk
from tkinter import ttk
class Demo1:
def __init__(self, master):
self.master = master
self.frame = tk.Frame(self.master)
self.frame.grid()
grupo1 = ttk.LabelFrame(self.frame, text='Nomes Pilotos')
grupo1.grid(row = 0, column = 0, padx=10, pady=10, sticky = 'w')
botao1 = ttk.Button(grupo1, width=18, text='Amaral SILVA', command = lambda : self.escreve('Amaral'))
botao1.grid(padx=10, pady=5)
botao2 = ttk.Button(grupo1, width=18, text='Jorge CASTRO', command = lambda : self.escreve('Jorge'))
botao2.grid(padx=10, pady=5)
grupo2 = ttk.LabelFrame(master, text = 'Informação:')
grupo2.grid(row = 1, column = 0, columnspan = 4, padx = 10, pady = 1, sticky = 'w')
texto = tk.Text(grupo2, height=10, width=20, fg='white', bg='#3D7475',font=('Consolas', 12))
texto.grid()
def escreve(self, jogador):
texto.insert(END, jogador, ' é fixe!')
def main():
root = tk.Tk()
Demo1(root)
root.mainloop()
if __name__ == '__main__':
main()