Facebook
From Pi, 5 Days ago, written in Python.
Embed
Download Paste or View Raw
Hits: 64
  1. from tkinter import *
  2. import random
  3.  
  4. def use():
  5.     if buttons[guzik] == min(buttons.values()):
  6.         guzik.config(state = 'disabled', bg='green')
  7.         #buttons.pop(guzik) #  error
  8.     else:
  9.         guzik.config(state = 'disabled', bg='red')
  10.    
  11. num = [x for x in range(1000)]
  12. buttons = {}
  13.  
  14. root = Tk()
  15.  
  16. for i in range(25):    
  17.     guzik = Button(root, text = random.sample(num,1), height = 1, width = 7)
  18.     guzik.grid(row = int(i/5), column = i%5)
  19.     buttons[guzik] = int(guzik.cget('text'))
  20.    
  21. print(buttons)
  22.  
  23. root.mainloop()
  24.