python - turtle delete writing on Screen and Rewrite -


in code, under function, do:

t = turtle.turtle() t.write(name, font=("arial", 11, "normal"), align="center") 

but when change screen, want delete text, , rewrite somewhere else. know "easy way out" of clearing whole screen. there way delete writing?

i have tried drawing white square on text, did not work.

has tried different?

at first, thought simple matter of going same location , rewriting same text in same font using white ink. surprisingly, left black smudge , took 10 overwrites in white make presentable. however, came upon better solution, use separate turtle write text want dispose of , clear turtle before rewriting text in new position, else on screen, drawn different turtle, remains:

import turtle import time  def erasablewrite(tortoise, name, font, align, reuse=none):     eraser = turtle.turtle() if reuse none else reuse     eraser.hideturtle()     eraser.up()     eraser.setposition(tortoise.position())     eraser.write(name, font=font, align=align)     return eraser  t = turtle.turtle() t.hideturtle() t.up()  t.goto(-100,100) t.write("permanent", font=("arial", 20, "normal"), align="center")  t.goto(100,100) eraseble = erasablewrite(t, "erasable", font=("arial", 20, "normal"), align="center")  time.sleep(1)  eraseble.clear()  t.goto(-100, -100) erasable = erasablewrite(t, "erasable", font=("arial", 20, "normal"), align="center", reuse=eraseble)  turtle.done() 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -