0
I made a program that plays dice. I used the graphical library Tkinter to create buttons and Labels. I use the button to activate a function that generates a random number, but the label does not change text, IE, the result of the data does not appear. Does anyone know how I proceed? Follow the code:
import tkinter
import tkinter.font
from random import randint
class Dice():
def __init__(self):
self.window = tkinter.Tk()
def random_number(self):
self.result = str(randint(0,100))
def elements(self):
self.result = 'Resultado do dado'
self.font = tkinter.font.Font(family='Arial', size=20)
self.texto = tkinter.Label(text=self.result, width=20, height=2, font=self.font)
self.cem = tkinter.Button(text='D100', width=10, height=2,font=self.font, command=self.random_number)
self.quatro = tkinter.Button(text='D4', width=10, height=2,font=self.font)
self.seis = tkinter.Button(text='D6', width=10, height=2,font=self.font)
self.oito = tkinter.Button(text='D8', width=10, height=2,font=self.font)
self.texto.grid(columnspan=2, row=0)
self.cem.grid(column=0, row=1)
self.quatro.grid(column=1, row=1)
self.seis.grid(column=0, row=2)
self.oito.grid(column=1, row=2)
dado = Dice()
dado.elements()