-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui_manager.py
42 lines (28 loc) · 839 Bytes
/
gui_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import tkinter as tk
import os
import hyperparameters as hp
Fenetre = tk.Tk()
world = tk.Canvas(Fenetre, width=hp.WIDTH, height=hp.HEIGHT)
world.pack()
close_flag = False
# --------------------------- EVENT HANDLING --------------------------
history = []
def on_closing():
global close_flag
close_flag = True
os.system("xset r on")
Fenetre.destroy()
def keyup(e):
if e.keysym in history:
history.pop(history.index(e.keysym))
history.append(e.keysym + "-UP")
def keydown(e):
# return # uncomment to disable human key inputs
if e.keysym not in history:
history.append(e.keysym)
def restart(e):
if e.keysm not in history:
history.append(e.keysym)
Fenetre.bind("<Key>", keydown)
Fenetre.bind("<KeyRelease>", keyup)
Fenetre.protocol("WM_DELETE_WINDOW", on_closing)