1234567891011121314151617181920212223242526272829303132 |
- import pygame
- import sys
- import GUI
- from random import randint
- pygame.init()
- screen = pygame.display.set_mode((300, 300))
- widgets = []
- for j in range(30):
- for i in range(30):
- widgets.append(GUI.Button(screen, text = '', width = 10, height = 10, x = 10*j, y = 10*i))
- widgets.append(GUI.Button(screen, text = '', width = 10, height = 10, x = 999, y = 999))
- while True:
- for value in range(len(widgets)):
- widgets[value].update()
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- sys.exit()
- elif event.type == pygame.MOUSEBUTTONDOWN:
- for value in range(900):
- if widgets[value].active(key = event.button):
- widgets[value].set_bg_color((randint(0, 255), randint(0, 255), randint(0, 255)))
- pygame.display.update()
|