|
1 | 1 | # Live Demo
|
| 2 | + |
2 | 3 | https://user-images.githubusercontent.com/67270567/226549542-cd786152-fcb2-43f9-ba1d-6d6994775f33.mp4
|
| 4 | + |
3 | 5 | Press the Play button to See the Output
|
4 | 6 |
|
5 | 7 | # Line by Line Explanation of the Code
|
@@ -86,3 +88,12 @@ The code sets up an event listener using the `listen()` method on the window obj
|
86 | 88 | - When the `a` key is pressed, the `move_left()` function is called.
|
87 | 89 | - When the `d` key is pressed, the `move_right()` function is called.
|
88 | 90 | - When the `c` key is pressed, the `clear()` function is called.
|
| 91 | + |
| 92 | +```python |
| 93 | + window.exitonclick() |
| 94 | +``` |
| 95 | +7. Exiting the Program |
| 96 | + |
| 97 | +The` exitonclick()` method is called on the window object to keep the window open until the user clicks on it, allowing them to view their drawings. |
| 98 | + |
| 99 | +8. In summary, the code sets up a simple drawing application that allows users to move a turtle around the screen and create drawings using basic keyboard input. It sets up event listeners to detect keyboard input, and responds to the input by calling specific functions to control the turtle's movement. The `clear()` function is defined to clear the screen, and the `exitonclick()` method is used to keep the window open until the user clicks on it. |
0 commit comments