pok_m.py

Created by pikube

Created on December 12, 2019

1.88 KB

ATTENTION: Ce programme exige toute la mémoire de la calculatrice, et est couplé aux autres scripts commençeant par pok_ (f,c,s, et a). Il requiert OMEGA 1.16.0-0 (allez voir https://github.com/Omega-Numworks/Omega).

Ce script contient le fonctionnement d’un menu, et quelques fonction utiles dans d’autres scripts.


from pok_f import *
from kandinsky import *
import time
def isov2(x):
  if x>=2:
    return 1
  else:
    return 0
def change():
  c=get_keys()
  time.sleep(0.001)
  c1=get_keys()
  if c!=c1:
    return 1
  else:
    return 0
      
class menu():
  #[string,var] formated
  def __init__(self,strs,func):
    self.strs=strs
    self.func=func
  def render(self,curs):
    txtbx()
    for loop in range(len(self.strs)):
      draw_string(self.strs[loop],150*((loop)%2)+50,40*(isov2(loop))+150,[255,255,255],[0,0,0])
    triangle(150*(curs%2)+40,40*(isov2(curs))+157)

def show(menus):
    prsd=0
    curs=0
    ch=0
    #transform is pressed to was pressed
    menus.render(curs)
    while prsd==0:
      if get_keys()==set():
        ch=1
      if get_keys()=={"up"} and ch==1:
        curs=(curs+1)%len(menus.strs)
        menus.render(curs)
        ch=0
      if get_keys()=={"left"} and ch==1:
        curs=(curs-1)%len(menus.strs)
        menus.render(curs)
        ch=0
      if get_keys()=={"right"} and ch==1:
        curs=(curs+2-len(menus.strs)%2)%len(menus.strs)
        menus.render(curs)
        ch=0
      if get_keys()=={"down"} and ch==1:
        curs=((curs-2)+len(menus.strs)%2)%len(menus.strs)
        menus.render(curs)
        ch=0
      if get_keys()=={"EXE"} and ch==1:
        prsd=1
      if get_keys()=={"OK"} and ch==1:
        prsd=1
        return("reinit","reinit")
    if type(menus.func[curs])==menu:  
      return [menus.func[curs],"other menu"]
    if type(menus.func[curs])==str:
      return [menus.func[curs],menus.func[curs]]
    if type(menus.func[curs])==pokemon:
      return [menus.func[curs],"pokemon"]     
def arbor(men):
  c=show(men)
  while 1:
    if c[1]==("reinit"):
      c=show(men)
    elif c[1]==("other menu"):
      c=show(c[0])
    else:
      return c
#next is used to see if pvs are positives 
def ispos(x):
  if x>0:
    return 1
  else:
    return 0

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.