Skip to content

Instantly share code, notes, and snippets.

@horstjens
Created June 10, 2022 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horstjens/993a2df03ccbf4b72005076688e2d4a1 to your computer and use it in GitHub Desktop.
Save horstjens/993a2df03ccbf4b72005076688e2d4a1 to your computer and use it in GitHub Desktop.
georgi1
import PySimpleGUI as sg
import random
import time
duration = 60
colors = ["black","white","grey","yellow","blue","red","green","orange","pink","cyan","purple"]
words = ["clack","clock","clonk","ding","dong","dang","clickety-click","cookie","cuckoo"]
start_time = time.time()
end_time = start_time + duration
score = 0
while time.time() < end_time:
time_left = end_time - time.time()
random.shuffle(colors)
word = random.choice(words)
buttons = ["click",word]
random.shuffle(buttons)
x=random.randint(-600,600)
y=random.randint(-400,400)
result = sg.popup(
f"click the word 'click' as fast as you can!\nScore: {score}\ntime left:{time_left:.0f}",
title="press ESC to quit",
button_color=(colors[0],colors[1] ),
background_color=colors[2],
text_color=colors[3],
auto_close=True,
auto_close_duration=1,
custom_text=(buttons[0],buttons[1]),
font=("Arial",20),
keep_on_top=True,
any_key_closes=True,
relative_location=(x,y)
#image=
)
print(result)
if result == "click":
score += 1
#elif result is not "__TIMEOUT__":
# break
elif result == "Escape:9":
break
print("bye")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment