0
Hello. I am working with Tkinter and I am at an impasse. I have nine buttons and each one prints a number. How can I make it so that after I press a button, no matter what button I press, a number always appears in the same position and when I press another button, no matter what button I press, another number appears next to the first one? Code:
# -*- coding: cp1252 -*-
from Tkinter import *
root = Tk()
root.minsize(620, 500)
root.title("Euromilhões virtual")
root.configure(background = 'blue')
def sorteio():
import time
import random
numeros = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
randw = random.sample(numeros, 1)
randx = random.sample(numeros, 1)
randy = random.sample(numeros, 1)
randz = random.sample(numeros, 1)
randt = random.sample(numeros, 1)
mostrar = Label(root, text = randw, bg = "blue", fg = "black", font = ('arial black', 40)).place(x = 110, y = 250)
mostra = Label(root, text = randx, bg = "blue", fg = "black", font = ('arial black', 40)).place(x = 190, y = 250)
amostra = Label(root, text = randy, bg = "blue", fg = "black", font = ('arial black', 40)).place(x = 270, y = 250)
show = Label(root, text = randz, bg = "blue", fg = "black", font = ('arial black', 40)).place(x = 350, y = 250)
visto = Label(root, text = randt, bg = "blue", fg = "black", font = ('arial black', 40)).place(x = 430, y = 250)
#Botões dos números:
def um():
one = Label(root, text = "1", bg = "blue", font = ('arial', 20))
def dois():
two = Label(root, text = "2", bg = "blue", font = ('arial', 20))
def tres():
three = Label(root, text = "3", bg = "blue", font = ('arial', 20))
def quatro():
four = Label(root, text = "4", bg = "blue", font = ('arial', 20))
def cinco():
five = Label(root, text = "5", bg = "blue", font = ('arial', 20))
def seis():
six = Label(root, text = "6", bg = "blue", font = ('arial', 20))
def sete():
seven = Label(root, text = "7", bg = "blue", font = ('arial', 20))
def oito():
eight = Label(root, text = "8", bg = "blue", font = ('arial', 20))
def nove():
nine = Label(root, text = "9", bg = "blue", font = ('arial', 20))
btn_um = Button(root, width = 5, text = "1", fg = "red", command = um).place(x = 90, y = 12)
btn_dois = Button(root, width = 5, text = "2", fg = "red", command = dois).place(x = 140, y = 12)
btn_tres = Button(root, width = 5, text = "3", fg = "red", command = tres).place(x = 190, y = 12)
btn_quatro = Button(root, width = 5, text = "4", fg = "red", command = quatro).place(x = 240, y = 12)
btn_cinco = Button(root, width = 5, text = "5", fg = "red", command = cinco).place(x = 290, y = 12)
btn_seis = Button(root, width = 5, text = "6", fg = "red", command = seis).place(x = 340, y = 12)
btn_sete = Button(root, width = 5, text = "7", fg = "red", command = sete).place(x = 390, y = 12)
btn_oito = Button(root, width = 5, text = "8", fg = "red", command = oito).place(x = 440, y = 12)
btn_nove = Button(root, width = 5, text = "9", fg = "red", command = nove).place(x = 490, y = 12)
#-----------------------------------------------------
nums_aposta = Label(root, text = "Números escolhidos:", bg = "blue", fg = "black").place(x = 250, y = 40)
botao_lotaria = Button(root, width = 20, height = 2, text = "Iniciar Lotaria", bg = "yellow", command = sorteio).place(x = 235, y = 150)
root.mainloop()