Created by cent20

Created on April 19, 2020

2.96 KB

Génère un menu pour paramétrer une application python sur la NumWorks.
Ceci est le script de démonstration. Le script utilisable est menu.py

```from kandinsky import *
from ion import keydown

from kandinsky import *
from ion import keydown

def wait(buttons=range(53)):  # Attends qu'une des touches précisées soit pressée
while True:
for i in buttons:
if keydown(i):
while keydown(i): True  # Fonction anti-rebond
return i

def omega():  # Vérificateur d'OS
try:
get_keys()
return True
except:
return False

n, g, f = (0, 0, 0), (96, 96, 96), (255, 183, 52)  # couleurs : réglages, optionsn focus
if omega():
f = (192, 53, 53)
chx = [1 for i in para]  # Valeurs par défaut
curs = 0  # Initialisation sur l'action
draw_string(titre, int(160 - 5 * len(titre)), 8, (42, 120, 224))
draw_string(action, int(160 - 5 * len(action)), 36, f)

draw_string(" " * 13, 150, 64 + i * 25, col)
txt = str(para[i][chx[i]])
if txt.find("\$") != -1:
txt2 = txt[txt.find("\$") + 1:]
txt = txt[:txt.find("\$")]
draw_string(" " * 32, 0, 64 + (i + 1) * 25)
draw_string(str(txt2), int(150 + (150 - 10 * len(str(txt2))) / 2), 64 + (i + 1) * 25, col)
draw_string(" " * 17, 140, 64 + (i) * 25)
draw_string(str(txt), int(150 + (150 - 10 * len(str(txt))) / 2), 64 + i * 25, col)
draw_string("<" * cursor, 140, 64 + i * 25, g)
draw_string(">" * cursor, 300, 64 + i * 25, g)

for i in range(len(para)):
draw_string(para[i][0], 10, 64 + i * 25, n)

while True:
r = wait((0, 1, 2, 3, 4, 52))
if r in (4, 52):  # Lance l'application
return [para[i][chx[i]] for i in range(len(para))]
elif r in (1, 2):
if curs == 0:
draw_string(action, int(160 - 5 * len(action)), 36, n)
else:
curs = (curs - 1 * (r == 1) + 1 * (r == 2)) % (len(para) + 1)
if curs == 0:
draw_string(action, int(160 - 5 * len(action)), 36, f)
else: