The module is a drawing library based on Tkinter, designed specifically for beginners. It simulates a “turtle” moving on the screen to draw graphics. It is simple and intuitive, making it ideal for learning programming fundamentals and graphic drawing concepts.
Basic Concepts
- Imagine a turtle with a pen on the screen, which you can control in terms of movement direction, speed, and pen state.
- As the turtle moves, the pen leaves a trail on the screen, forming various shapes.
Common Functions
-
Basic Movement:
<span class="language-plaintext">forward(distance)</span>/<span class="language-plaintext">fd(distance)</span>: Move forward by the specified distance.<span class="language-plaintext">backward(distance)</span>/<span class="language-plaintext">bk(distance)</span>: Move backward by the specified distance.<span class="language-plaintext">right(angle)</span>/<span class="language-plaintext">rt(angle)</span>: Rotate right by the specified angle.<span class="language-plaintext">left(angle)</span>/<span class="language-plaintext">lt(angle)</span>: Rotate left by the specified angle.
Pen Control:
<span class="language-plaintext">penup()</span>/<span class="language-plaintext">pu()</span>: Lift the pen, moving without leaving a trail.<span class="language-plaintext">pendown()</span>/<span class="language-plaintext">pd()</span>: Lower the pen, moving while leaving a trail.<span class="language-plaintext">pensize(width)</span>: Set the pen width.<span class="language-plaintext">pencolor(color)</span>: Set the pen color.
Screen Control:
<span class="language-plaintext">setup(width, height)</span>: Set the canvas size.<span class="language-plaintext">title(name)</span>: Set the window title.<span class="language-plaintext">done()</span>: Keep the window open.
Part 4 CourseTeaching methods: demonstration, group collaboration, practical methods.Presentation of the four-part course:
Course content:
Video presentation:Detailed course:
Files shared via cloud storage: Python Part 4
Link: https://pan.baidu.com/s/1oH__vumppOfA5MJ4sl9sbw Extraction code: 33nr
— Shared by Baidu Cloud Super Member v7