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

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.