a script to precisely draw on the screen with the turtle module
from turtle import * from ion import * from time import * from kandinsky import draw_string as ds, fill_rect as fr from math import fabs def pp(s,rs="",rx=310): fr(0,202,320,20,(192,)*3) ds(s,0,202,(0,)*3,(192,)*3) ds(rs,rx,202,(0,)*3,(192,)*3) def rr(s=""): do=True t="" m="" pp(s) cdt=True while do: if keydown(KEY_ZERO): t+="0" elif keydown(KEY_ONE): t+="1" elif keydown(KEY_TWO): t+="2" elif keydown(KEY_THREE): t+="3" elif keydown(KEY_FOUR): t+="4" elif keydown(KEY_FIVE): t+="5" elif keydown(KEY_SIX): t+="6" elif keydown(KEY_SEVEN): t+="7" elif keydown(KEY_EIGHT): t+="8" elif keydown(KEY_NINE): t+="9" elif keydown(KEY_OK): do=False elif keydown(KEY_MINUS): if m=="-": m="" else: m="-" elif keydown(KEY_BACKSPACE): t="" else: cdt=False if cdt: sleep(0.17) pp(s+m+t,rs="escape: 200",rx=210) else: sleep(0.02) cdt=True try: return int(m+t) except: return 0 go=True s=0.1 pen="z" l="z" co=[10,15] penup() goto(0,0) while go: if keydown(KEY_UP): goto(position()[0],position()[1]+co[0]) elif keydown(KEY_DOWN): goto(position()[0],position()[1]-co[0]) elif keydown(KEY_LEFT): goto(position()[0]-co[0],position()[1]) elif keydown(KEY_RIGHT): goto(position()[0]+co[0],position()[1]) elif keydown(KEY_COMMA): left(co[1]) elif keydown(KEY_POWER): right(co[1]) elif keydown(KEY_XNT): forward(co[0]) elif keydown(KEY_LOG): backward(co[0]) elif keydown(KEY_OK): if isdown(): penup() pen="U" else: pendown() pen="D" sleep(0.2) elif keydown(17): if rr("1=clear? ")==1: reset() s=0.1 pen="z" l="z" co=[10,15] elif keydown(KEY_SHIFT): if s>0.001: s/=2 sleep(0.2) elif keydown(KEY_ALPHA): s*=2 sleep(0.2) elif keydown(16): xy=rr("x: "),rr("y: ") if fabs(xy[0])<200 and fabs(xy[1])<200: goto(xy[0],xy[1]) elif keydown(KEY_VAR): setheading(rr("deg: ")) elif keydown(KEY_LN): co[0]=rr("pix: ") elif keydown(21): co[1]=rr("deg: ") elif keydown(KEY_EXP): if l=="W": color('black') l="K" else: color('white') l="W" a=pen+l+str(round(s,3)) b="; xy"+str(round(position()[0])) +":"+ str(round(position()[1])) c="; h"+str(round(heading())) d="; p"+str(co[0]) + " d"+str(co[1]) pp(a+b+c+d) sleep(s)