tutorfree

Mega-Sena-Tk

Aug 28th, 2020 (edited)
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. try:
  2.     from tkinter import *
  3. except:
  4.     from Tkinter import *
  5.  
  6. import random
  7.  
  8. janela = Tk()
  9. janela.title("Megasena")
  10.  
  11.  
  12. def loteria():
  13.  
  14.     numero=int(apostas.get())
  15.     sorteio = list(range(numero))
  16.     for item in sorteio:
  17.         sorteio[item] = random.sample(range(1, 61), 6)
  18.         sorteio[item].sort()
  19.         lista.insert(item," ".join(map(str, sorteio[item])))
  20.  
  21. lbApostas = Label(janela, text="Digite o número de apostas: ")
  22. lbApostas.place(x=10, y=20)
  23.  
  24. apostas = Entry(janela)
  25. apostas.place(x=230, y=20, width=45)
  26. apostas.focus_set()
  27.  
  28. btGerar = Button(janela, text="Gerar", width=10, command=loteria)
  29. btGerar.place(x=280, y=16)
  30.  
  31. lista = Listbox(janela)  
  32. lista.place(x=10, y=60, width=180)
  33.  
  34. btLimpar = Button(janela, text = "Limpar apostas", width=10, command = lambda listbox=lista: lista.delete(0,END))
  35. btLimpar.place(x=280, y=50)
  36.  
  37. btApagar = Button(janela, text = "Apagar jogo", width=10, command = lambda listbox=lista: lista.delete(ANCHOR))
  38. btApagar.place(x=10, y=260)
  39.  
  40. janela.geometry("410x300+200+200")
  41. janela.mainloop()
  42.  
Add Comment
Please, Sign In to add comment