gcls.py

Created by steveg1cmz

Created on August 09, 2023

1.27 KB

Compares graphic clear screen for various calculators. (Set isNumworks etc. yourself) (turtle.reset is an alternative to turtle.clear)

Maybe call gcls(), or just use it as a reminder of what’s available on a platform. Tested on 19.4.0


# Type your text here#gCls
"""Clearscreen: Clear graphics screen 
Shows how to clear the screen on calculators.
Tested only on Numworks.

Note: You may also want to print to clear the text screen.

Imp:
Casio: casioplot.clearscreen()
HP: Use PPL instead
Numworks: kandinsky.fill_rect()
TI: ti_draw.clear()
Turtle: turtle.clear() but not in Numworks!

Only Numworks fill with colour.
But others might be able to fill separately.
"""

__version__ = "0.01"

#customise (or: use try)
showme=True
isCasio=False
isHP=False
isNumworks=True
isTI=False
isturtleclear=False
#end customise

if isCasio:
  try: from casioplot import clearscreen
  except: isCasio=False

if isNumworks:
  try: from kandinsky import fill_rect
  except: isNumworks=False

if isTI:
  try: from ti_draw import clear
  except: isTI=False

if isturtleclear:
  try: from turtle import clear
  except: isturtleclear=False

def gcls(colour):
  """Clear the screen.  
  Hint: turtle pensize is not a useful tech.
  """
  if isCasio:
    clearscreen() 
  elif isNumworks:
    fill_rect(0,0,320,240,colour)
  elif isTI or isturtleclear:
     clear()
  else: pass
    
if showme or __name__ == "__main__":
  if isNumworks:
    from turtle import *
    color("green")
    circle(5) #show something
    gcls("red") #clear screen