Last active
          July 27, 2024 16:50 
        
      - 
      
- 
        Save t-wy/3cc6561d3e7b5585886a2a895068a048 to your computer and use it in GitHub Desktop. 
    A paint application using Python Turtle
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import turtle | |
| turtle.tracer(False) | |
| turtle.hideturtle() | |
| """ | |
| Paint Application using Python Turtle | |
| by t-wy | |
| """ | |
| def save(): | |
| turtle.getscreen().getcanvas().postscript(colormode='color', file="drawing.eps") | |
| def draw(x, y): | |
| t.ondrag(None) | |
| t.down() | |
| t.goto(x, y) | |
| t.up() | |
| turtle.update() | |
| t.ondrag(draw) | |
| def move(x, y): | |
| turtle.onscreenclick(None) | |
| t.goto(x, y) | |
| turtle.onscreenclick(move) | |
| turtle.update() | |
| t = turtle.Turtle() | |
| t.shape("square") | |
| t.fillcolor("") | |
| t.up() | |
| # dirty hack to hide the border completely | |
| drawturtle_backup = t._drawturtle | |
| def _drawturtle(*args, **kwargs): | |
| bkup = t._pencolor | |
| t._pencolor = "" | |
| drawturtle_backup(*args, **kwargs) | |
| t._pencolor = bkup | |
| t._drawturtle = _drawturtle | |
| t.turtlesize(1000000, 1000000) | |
| ts = turtle.getscreen() | |
| t.ondrag(draw) | |
| turtle.onscreenclick(move) | |
| turtle.update() | |
| turtle.onkeypress(save, "space") # Press Space to Save | |
| turtle.listen() | |
| turtle.done() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment