dirluxe.py

Created by mobluse

Created on October 11, 2024

1.69 KB

Dirluxe shows dir() of a module or a type on the graphics screen. This is helpful during program development to show each function in the modules. You can use the toolbox to type an import module and you don’t have to remove “import ”. Examples of supported modules: builtins, math, matplotlib.pyplot, and ion. Default is all i.e. display all modules - press OK or EXE to advance. Press shift +OK or shift+EXE to repeat current module from top. Hold shift to pause scrolling. You can also input a type e.g. {}, [], (), "", 1, 1.0, 1j, and {1}. You can use run(), run(""), and run("math") etc. in the shell.


from kandinsky import *
def ds(s,x,y,i=0):
  if i:
    draw_string(s,x,y,"blue","yellow")
  else:
    draw_string(s,x,y,"yellow","blue")
def run(ins="input"):
  ms=["micropython","builtins","math","cmath","matplotlib.pyplot","numpy","turtle","random","kandinsky","ion","time"]
  ms.sort()
  for m in ms:
    exec("import "+m)
  ms.extend(["set","dict","list","tuple","str","int","float","1j"])
  if ins=="input":
    ins=input("Module/type: [all] ")
  if ins=="" or ins=="all":
    ins=ms
  elif ins.startswith("import "):
    ins=[ins[7:]]
  else:
    ins=[ins]
  for m in ins:
    shift=True
    while shift:
      s=m+": "
      a=eval("dir("+m+")")
      #for i in eval("dir("+m+")"):
      #  a+=[i]
      a.sort()
      for i in a:
        s+=i+" "
      s=s[:-1]+"!"
      print(s)
      first=True
      cs=""
      x=0
      for i in range(0,len(s),32):
        y=3
        fill_rect(0,0,320,240,"blue")
        for c in s[i:i+384]:
          if c=="!":
            ds(cs,x,y)
            cs=""
            i=-1
            break
          cs+=c
          if len(cs)>=32:
            ds(cs,x,y)
            cs=""
            y+=18
            if y>12*18:
              y=3
              time.sleep(.2)
              if first:
                time.sleep(4)
                first=False
              while ion.keydown(ion.KEY_SHIFT):
                pass
        if i<0:
          break
      time.sleep(1)
      p="Press OK!"
      ds(p,23*10,11*18+3,1)
      while ion.keydown(ion.KEY_OK) or ion.keydown(ion.KEY_EXE):
        time.sleep(0.05)
      while not (ion.keydown(ion.KEY_OK) or ion.keydown(ion.KEY_EXE)):
        time.sleep(0.05)
      shift=ion.keydown(ion.KEY_SHIFT)
  input(p[:-1]+" or EXE!")
run()

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 <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.