Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try:
- from tkinter import *
- except:
- from Tkinter import *
- import random
- janela = Tk()
- janela.title("Megasena")
- def loteria():
- numero=int(apostas.get())
- sorteio = list(range(numero))
- for item in sorteio:
- sorteio[item] = random.sample(range(1, 61), 6)
- sorteio[item].sort()
- lista.insert(item," ".join(map(str, sorteio[item])))
- lbApostas = Label(janela, text="Digite o número de apostas: ")
- lbApostas.place(x=10, y=20)
- apostas = Entry(janela)
- apostas.place(x=230, y=20, width=45)
- apostas.focus_set()
- btGerar = Button(janela, text="Gerar", width=10, command=loteria)
- btGerar.place(x=280, y=16)
- lista = Listbox(janela)
- lista.place(x=10, y=60, width=180)
- btLimpar = Button(janela, text = "Limpar apostas", width=10, command = lambda listbox=lista: lista.delete(0,END))
- btLimpar.place(x=280, y=50)
- btApagar = Button(janela, text = "Apagar jogo", width=10, command = lambda listbox=lista: lista.delete(ANCHOR))
- btApagar.place(x=10, y=260)
- janela.geometry("410x300+200+200")
- janela.mainloop()
Add Comment
Please, Sign In to add comment