Phương pháp 1. Sử dụng ANSI ESCAPE CODE Để thêm màu sắc và kiểu dáng cho văn bản, bạn nên tạo một lớp có tên là ANSI, bên trong lớp này khai báo các cấu hình về văn bản và màu sắc bằng mã ANSI. Các chức năng được sử dụng. lai lịch. cho phép định dạng nền. Accepts ANSI codes between 40 and 47, 100 and 107
Generally How do I change the background of my Python GUI? The default background color of a Tkinter GUI is gray. You can change this to any color according to the needs of your application. There are two ways to change the background color of a window in Tkinter. By using the configure[bg=] method of the tkinter. Tk class
Here You Can Watch The Video Two Ways To Change Background Colors – Python Kivy GUI
Similarly, Change Background Color And Text Color of Labels – Python
Frequently Asked Questions[FAQ]
How can I change my background color?
Select Start > Settings > Personalization > Colors, and then choose your own color, or let Windows pull an accent color from your background
How do I change colors in Python?
To make some of your text more readable, you can use ANSI escape codes to change the colour of the text output in your python program. A good use case for this is to to highlight errors. Add Colour to Text in Python
Text colorRedCode31Text styleBoldCode1Background colorRed•
How do you define a color in Python?
In the RGB color model, any color can be generated by mixing 3 primary colors, namely, Red, Green, and Blue. In this model, a color can be described by specifying a group of 3 numeric values [typically ranging from 0 to 255],each specifying the intensity of Red, Green, and Blue colors present in a given color
What we use to change the background color any widget in Python?
We can customize the tkinter widgets using the tkinter. ttk module. Tkinter. ttk module is used for styling the tkinter widgets such as setting the background color, foreground color, activating the buttons, adding images to labels, justifying the height and width of widgets, etc
How do I change the color of a Button in Python?
We can also change the foreground color by using the ‘fg’ property of the button widget in Tkinter. We can also use the configure method to change the color. As we know that we can use the ‘bg’ and ‘fg’ property of the Button widget to change the color, we need to pass this variable while using the Button object
What is Tkinter default color?
The default background color of a GUI with Tkinter is grey. You can change that to any color based on your application’s requirement
How do you highlight text in Python?
Adding Highlighted Text
- cú pháp. paragraph. add_run[]. font. highlight_color = Colour_Name
- Parameter. Colour_Name. It is the name of the colour assign to highlight the text. It is the member of the WD_COLOR_INDEX
- Note. If we don’t assign the colour then default colour is NONE
How do you change the font style in Python?
In your Python program, import tkinter. font as font, create font. Font[] object with required options and assign the Font object to font option of Button
How do you change the font in Python?
Open the Python shell. Then, in the menu bar, under Python [directly to the right of the Apple icon], you will find Preferences. Under this, you will find the Font/Tabs option, and you can change the font size according to your preference
How do I change the font color in Pycharm?
Press Ctrl+Alt+S to open the IDE settings and select Editor . Color Scheme . Python. Select any code element you want to customize and clear the corresponding Inherit values from checkbox to change inherited color settings for this element; then specify your color and font settings
Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967
Imagine a robotic turtle starting at [0, 0] in the x-y plane. After an
>>> turtle.setheading[90] >>> turtle.heading[] 90.09, give it the command
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.00, and it moves [on-screen. ] 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01, and it rotates in-place 25 degrees clockwise
Turtle star
Turtle can draw intricate shapes using programs that repeat simple moves
from turtle import * color['red', 'yellow'] begin_fill[] while True: forward[200] left[170] if abs[pos[]] >> turtle.setheading[90] >>> turtle.heading[] 90.08 module is an extended reimplementation of the same-named module from the Python standard distribution up to version Python 2. 5
It tries to keep the merits of the old turtle module and to be [nearly] 100% compatible with it. This means in the first place to enable the learning programmer to use all the commands, classes and methods interactively when using the module from within IDLE run with the
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.03 switch
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04 for the underlying graphics, it needs a version of Python installed with Tk support
The object-oriented interface uses essentially two+two classes
The
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
5 class defines graphics windows as a playground for the drawing turtles. Its constructor needs a>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
6 or a>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
7 as argument. It should be used when>>> turtle.setheading[90] >>> turtle.heading[] 90.0
8 is used as part of some applicationThe function
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
9 returns a singleton object of a>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
5 subclass. This function should be used when>>> turtle.setheading[90] >>> turtle.heading[] 90.0
8 is used as a standalone tool for doing graphics. As a singleton object, inheriting from its class is not possibleTất cả các phương thức của TurtleScreen/Screen cũng tồn tại dưới dạng hàm, tôi. e. as part of the procedure-oriented interface
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
402 [alias.>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
403] defines Turtle objects which draw on a>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
5. Hàm tạo của nó cần một Canvas, ScrolledCanvas hoặc TurtleScreen làm đối số, vì vậy các đối tượng RawTurtle biết nơi để vẽCó nguồn gốc từ RawTurtle là phân lớp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
405 [bí danh.>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
406], dựa trên “đối tượng”>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
407 được tạo tự động, nếu chưa cóTất cả các phương thức của RawTurtle/Turtle cũng tồn tại dưới dạng hàm, tôi. e. một phần của giao diện hướng thủ tục
Giao diện thủ tục cung cấp các chức năng bắt nguồn từ các phương thức của các lớp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0407 và
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0405. Chúng có cùng tên với các phương thức tương ứng. Một đối tượng màn hình được tạo tự động bất cứ khi nào một hàm bắt nguồn từ phương thức Màn hình được gọi. Một đối tượng rùa [chưa được đặt tên] được tạo tự động bất cứ khi nào bất kỳ hàm nào bắt nguồn từ phương thức Rùa được gọi
Để sử dụng nhiều con rùa trên một màn hình, người ta phải sử dụng giao diện hướng đối tượng
Ghi chú
Trong tài liệu sau đây, danh sách đối số cho các hàm được đưa ra. Tất nhiên, các phương thức có đối số đầu tiên bổ sung self được bỏ qua ở đây
Tổng quan về các phương pháp Con rùa và Màn hình có sẵn¶
Phương pháp rùa¶
Chuyển động của rùa Di chuyển và vẽ>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0410.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0411
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0412.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0413.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0414
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0415.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0416
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0417.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0418
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0419 .
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0420.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0421
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0422
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0423
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0424.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0425
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0426
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0427
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0428
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0429
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0430
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0431
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0432
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0433Cho biết trạng thái của Rùa
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0434.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0435
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0436
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0437
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0438
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0439
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0440Cài đặt và đo lường
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0441
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0442Điều khiển bút Trạng thái vẽ
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0443.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0444.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0445
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0446.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0447.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0448
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0449.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0450
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0451
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0452Kiểm soát màu sắc
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0453
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0454
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0455Filling
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0456
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0457
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0458Kiểm soát bản vẽ nhiều hơn
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0459
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0460
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0461Trạng thái rùaKhả năng hiển thị
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0462.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0463
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0464.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0465
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0466Vẻ bề ngoài
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0467
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0468
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0469.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0470
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0471
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0472
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0473
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0474
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0475
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0476Sử dụng các sự kiện
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0477
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0478
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0479Phương pháp rùa đặc biệt
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0480
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0481
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0482
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0483
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0484.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0485
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0486
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0487
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0488
Các phương thức của TurtleScreen/Screen¶
Kiểm soát cửa sổ>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0489
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0490
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0491
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0492
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0493
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0494kiểm soát hoạt ảnh
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0495
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0496
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0497Sử dụng các sự kiện màn hình
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0498
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0499.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01200
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01201
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0477.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01203
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01204
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01205.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01206Cài đặt và phương pháp đặc biệt
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01207
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01208
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01209
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01210
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01211.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01212
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01213
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01214
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01215Phương thức nhập liệu
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01216
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01217Các phương pháp dành riêng cho Màn hình
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01218
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01219
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01220
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01221
Các phương thức của RawTurtle/Turtle và các hàm tương ứng¶
Hầu hết các ví dụ trong phần này đề cập đến một cá thể Rùa có tên là
>>> turtle.setheading[90] >>> turtle.heading[] 90.08
Chuyển động của rùa¶
rùa. về phía trước[khoảng cách] ¶ . turtle.fd[khoảng cách] ¶khoảng cách – một số [số nguyên hoặc số thực]
Di chuyển rùa về phía trước theo khoảng cách xác định, theo hướng rùa đang đi
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04rùa. lùi lại[khoảng cách] ¶ . turtle.bk[khoảng cách] ¶ . turtle.lùi lại[khoảng cách] ¶
khoảng cách - một con số
Di chuyển rùa lùi một đoạn, ngược với hướng rùa đi. Không thay đổi tiêu đề của rùa
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.012rùa. phải[góc] ¶ . turtle.rt[góc] ¶
góc – một số [số nguyên hoặc số float]
Xoay rùa sang phải theo đơn vị góc. [Các đơn vị theo độ mặc định, nhưng có thể được đặt thông qua các hàm
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0441 và
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0442. ] Định hướng góc phụ thuộc vào chế độ con rùa, xem
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01207
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.040rùa. trái[góc] ¶ . turtle.lt[góc] ¶
góc – một số [số nguyên hoặc số float]
Xoay rùa sang trái theo đơn vị góc. [Các đơn vị theo độ mặc định, nhưng có thể được đặt thông qua các hàm
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0441 và
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0442. ] Định hướng góc phụ thuộc vào chế độ con rùa, xem
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01207
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.044rùa. goto[x , y . =None]¶turtle.đặt vị trí[x , y . =None]¶turtle.vị trí đặt[x , y=None]¶Parameters
x – một số hoặc một cặp/vectơ số
y – một số hoặc
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229
Nếu y là
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, x phải là một cặp tọa độ hoặc một
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01231 [e. g. như được trả về bởi
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0435]
Di chuyển rùa đến một vị trí tuyệt đối. Nếu bút xuống, vẽ đường. Không thay đổi hướng của rùa
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.049rùa. setx[x] ¶
x – một số [số nguyên hoặc số thực]
Đặt tọa độ đầu tiên của rùa thành x, giữ nguyên tọa độ thứ hai
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.050rùa. bộ[y] ¶
y – một số [số nguyên hoặc số thực]
Đặt tọa độ thứ hai của rùa thành y, giữ nguyên tọa độ đầu tiên
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.051rùa. tiêu đề[to_angle] ¶ . turtle.seth[to_angle] ¶
to_angle – a number [integer or float]
Đặt hướng của rùa thành to_angle. Dưới đây là một số hướng phổ biến theo độ
chế độ căn bản
chế độ logo
0 - đông
0 - bắc
90 - bắc
90 - đông
180 - tây
180 - nam
270 - nam
270 - tây
>>> turtle.setheading[90] >>> turtle.heading[] 90.0rùa. nhà[] ¶
Di chuyển con rùa đến điểm gốc – tọa độ [0,0] – và đặt tiêu đề của nó thành hướng bắt đầu [tùy thuộc vào chế độ, xem
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01207]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0rùa. hình tròn[bán kính , phạm vi=None, steps=None]¶Parameters
bán kính - một số
phạm vi – một số [hoặc
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229]các bước – một số nguyên [hoặc
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229]
Vẽ đường tròn có bán kính cho trước. Trung tâm là các đơn vị bán kính bên trái của con rùa; . Nếu phạm vi không được đưa ra, hãy vẽ toàn bộ vòng tròn. Nếu phạm vi không phải là một vòng tròn đầy đủ, một điểm cuối của vòng cung là vị trí bút hiện tại. Vẽ cung theo hướng ngược chiều kim đồng hồ nếu bán kính dương, ngược lại theo chiều kim đồng hồ. Cuối cùng, hướng của rùa được thay đổi theo mức độ
Vì hình tròn được xấp xỉ bằng một đa giác đều nội tiếp, các bước xác định số bước sẽ sử dụng. Nếu không được cung cấp, nó sẽ được tính toán tự động. Có thể được sử dụng để vẽ đa giác thông thường
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.040rùa. chấm[kích thước=Không, *color]¶Parameters
size – một số nguyên >= 1 [nếu có]
màu – một chuỗi màu hoặc một bộ màu số
Vẽ một chấm tròn có kích thước đường kính, sử dụng màu. Nếu kích thước không được cung cấp, thì tối đa pensize+4 và 2*pensize được sử dụng
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.041rùa. đóng dấu[] ¶
Đóng dấu một bản sao của hình con rùa lên canvas ở vị trí con rùa hiện tại. Trả lại một tem_id cho tem đó, có thể được sử dụng để xóa nó bằng cách gọi
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01236
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.042rùa. dấu xóa[dấu] ¶
Stampid – một số nguyên, phải là giá trị trả về của lệnh gọi
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0429 trước đó
Xóa tem với tem đã cho
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.043rùa. dấu xóa[n=Không]¶Parameters
n – một số nguyên [hoặc
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229]
Xóa tất cả hoặc n tem đầu tiên/cuối cùng của rùa. Nếu n là
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, xóa tất cả tem, nếu n > 0 xóa n tem đầu tiên, ngược lại nếu n < 0 xóa n tem cuối cùng
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.044rùa. hoàn tác[] ¶
Hoàn tác [nhiều lần] [các] hành động rùa cuối cùng. Number of available undo actions is determined by the size of the undobuffer
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.045rùa. tốc độ[tốc độ=Không]¶Parameters
tốc độ – một số nguyên trong phạm vi 0. 10 hoặc dây tốc độ [xem bên dưới]
Đặt tốc độ của rùa thành một giá trị nguyên trong phạm vi 0. 10. Nếu không có đối số nào được đưa ra, hãy trả về tốc độ hiện tại
Nếu đầu vào là một số lớn hơn 10 hoặc nhỏ hơn 0. 5, tốc độ được đặt thành 0. Dây tốc độ được ánh xạ tới các giá trị tốc độ như sau
“nhanh nhất”. 0
"Nhanh". 10
"thông thường". 6
"chậm". 3
“chậm nhất”. 1
Tốc độ từ 1 đến 10 thực thi hoạt ảnh vẽ đường thẳng và xoay rùa ngày càng nhanh hơn
Chú ý. tốc độ = 0 có nghĩa là không có hoạt ảnh nào diễn ra. tiến/lùi khiến rùa nhảy và tương tự trái/phải khiến rùa quay ngay lập tức
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.046
Tell Turtle’s state¶
turtle. position[] ¶ turtle. pos[] ¶Return the turtle’s current location [x,y] [as a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01231 vector]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.047turtle. towards[x , y=None] ¶Parameters
x – a number or a pair/vector of numbers or a turtle instance
y – a number if x is a number, else
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229
Return the angle between the line from turtle position to position specified by [x,y], the vector or the other turtle. This depends on the turtle’s start orientation which depends on the mode - “standard”/”world” or “logo”
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.048turtle. xcor[] ¶
Return the turtle’s x coordinate
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.049turtle. ycor[] ¶
Return the turtle’s y coordinate
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0120turtle. heading[] ¶
Return the turtle’s current heading [value depends on the turtle mode, see
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01207]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0121turtle. distance[x , y=None] ¶Parameters
x – a number or a pair/vector of numbers or a turtle instance
y – a number if x is a number, else
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229
Return the distance from the turtle to [x,y], the given vector, or the given other turtle, in turtle step units
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0122
Settings for measurement¶
turtle. degrees[fullcircle=360. 0] ¶Parametersfullcircle – a number
Set angle measurement units, i. e. set number of “degrees” for a full circle. Default value is 360 degrees
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0123turtle. radians[] ¶
Set the angle measurement units to radians. Equivalent to
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01244
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0124
Pen control¶
Drawing state¶
turtle. pendown[] ¶ turtle. pd[] ¶ turtle. down[] ¶Pull the pen down – drawing when moving
turtle. penup[] ¶ turtle. pu[] ¶ turtle. up[] ¶Pull the pen up – no drawing when moving
turtle. pensize[width=None] ¶ turtle. width[width=None] ¶Parameterswidth – a positive number
Set the line thickness to width or return it. If resizemode is set to “auto” and turtleshape is a polygon, that polygon is drawn with the same line thickness. If no argument is given, the current pensize is returned
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0125turtle. pen[pen=None , **pendict] ¶Parameters
pen – a dictionary with some or all of the below listed keys
pendict – one or more keyword-arguments with the below listed keys as keywords
Return or set the pen’s attributes in a “pen-dictionary” with the following key/value pairs
“shown”. True/False
“pendown”. True/False
“pencolor”. color-string or color-tuple
“fillcolor”. color-string or color-tuple
“pensize”. positive number
“speed”. number in range 0. 10
“resizemode”. “auto” or “user” or “noresize”
“stretchfactor”. [positive number, positive number]
“outline”. positive number
“tilt”. number
This dictionary can be used as argument for a subsequent call to
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0451 to restore the former pen-state. Moreover one or more of these attributes can be provided as keyword-arguments. This can be used to set several pen attributes in one statement
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0126turtle. isdown[] ¶
Return
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01246 if pen is down,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01247 if it’s up
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0127
Color control¶
turtle. pencolor[*args] ¶Return or set the pencolor
Four input formats are allowed
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0454
Return the current pencolor as color specification string or as a tuple [see example]. May be used as input to another color/pencolor/fillcolor call
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01249
Set pencolor to colorstring, which is a Tk color specification string, such as
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01250,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01251, or
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01252
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01253
Set pencolor to the RGB color represented by the tuple of r, g, and b. Each of r, g, and b must be in the range 0. colormode, where colormode is either 1. 0 or 255 [see
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01208]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01255
Set pencolor to the RGB color represented by r, g, and b. Each of r, g, and b must be in the range 0. colormode
If turtleshape is a polygon, the outline of that polygon is drawn with the newly set pencolor
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0128turtle. fillcolor[*args] ¶
Return or set the fillcolor
Four input formats are allowed
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0455
Return the current fillcolor as color specification string, possibly in tuple format [see example]. Có thể được sử dụng làm đầu vào cho lệnh gọi color/pencolor/fillcolor khác
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01257
Đặt màu tô thành chuỗi màu, là chuỗi đặc tả màu Tk, chẳng hạn như
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01250,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01251 hoặc
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01252
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01261
Đặt màu tô thành màu RGB được biểu thị bằng bộ của r, g và b. Mỗi r, g và b phải nằm trong phạm vi 0. colormode, trong đó colormode là 1. 0 hoặc 255 [xem
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01208]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01263
Đặt màu tô thành màu RGB được biểu thị bằng r, g và b. Each of r, g, and b must be in the range 0. chế độ màu
If turtleshape is a polygon, the interior of that polygon is drawn with the newly set fillcolor
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0129turtle. color[*args] ¶
Return or set pencolor and fillcolor
Several input formats are allowed. They use 0 to 3 arguments as follows
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0453
Return the current pencolor and the current fillcolor as a pair of color specification strings or tuples as returned by
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0454 and
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0455
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01267,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01268,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01269
Inputs as in
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0454, set both, fillcolor and pencolor, to the given value
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01271,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01272
Equivalent to
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01273 and
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01274 and analogously if the other input format is used
If turtleshape is a polygon, outline and interior of that polygon is drawn with the newly set colors
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0400
See also. Screen method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01208
Filling¶
turtle. filling[] ¶Return fillstate [
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01246 if filling,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01247 else]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0401turtle. begin_fill[] ¶
To be called just before drawing a shape to be filled
turtle. end_fill[] ¶Fill the shape drawn after the last call to
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0457
Whether or not overlap regions for self-intersecting polygons or multiple shapes are filled depends on the operating system graphics, type of overlap, and number of overlaps. For example, the Turtle star above may be either all yellow or have some white regions
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0402
More drawing control¶
turtle. reset[] ¶Delete the turtle’s drawings from the screen, re-center the turtle and set variables to the default values
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0403turtle. clear[] ¶
Delete the turtle’s drawings from the screen. Do not move turtle. State and position of the turtle as well as drawings of other turtles are not affected
turtle. write[arg , move=False , align='left' , font=['Arial', 8, 'normal']] ¶Parametersarg – object to be written to the TurtleScreen
move – True/False
align – one of the strings “left”, “center” or right”
font – a triple [fontname, fontsize, fonttype]
Write text - the string representation of arg - at the current turtle position according to align [“left”, “center” or “right”] and with the given font. If move is true, the pen is moved to the bottom-right corner of the text. By default, move is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01247
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0404
Turtle state¶
Visibility¶
turtle. hideturtle[] ¶ turtle. ht[] ¶Make the turtle invisible. It’s a good idea to do this while you’re in the middle of doing some complex drawing, because hiding the turtle speeds up the drawing observably
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0405turtle. showturtle[] ¶ turtle. st[] ¶
Make the turtle visible
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0406turtle. isvisible[] ¶
Return
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01246 if the Turtle is shown,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01247 if it’s hidden
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0407
Appearance¶
turtle. shape[name=None] ¶Parametersname – a string which is a valid shapename
Set turtle shape to shape with given name or, if name is not given, return name of current shape. Shape with name must exist in the TurtleScreen’s shape dictionary. Initially there are the following polygon shapes. “arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”. To learn about how to deal with shapes see Screen method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01211
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0408turtle. resizemode[rmode=None] ¶Parameters
rmode – one of the strings “auto”, “user”, “noresize”
Set resizemode to one of the values. “auto”, “user”, “noresize”. If rmode is not given, return current resizemode. Different resizemodes have the following effects
“auto”. adapts the appearance of the turtle corresponding to the value of pensize
“user”. adapts the appearance of the turtle according to the values of stretchfactor and outlinewidth [outline], which are set by
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
469“noresize”. no adaption of the turtle’s appearance takes place
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01284 is called by
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0469 when used with arguments
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0409turtle. shapesize[stretch_wid=None , stretch_len=None , outline=None] ¶ turtle. turtlesize[stretch_wid=None , stretch_len=None , outline=None] ¶Parameters
stretch_wid – positive number
stretch_len – positive number
outline – positive number
Return or set the pen’s attributes x/y-stretchfactors and/or outline. Set resizemode to “user”. If and only if resizemode is set to “user”, the turtle will be displayed stretched according to its stretchfactors. stretch_wid is stretchfactor perpendicular to its orientation, stretch_len is stretchfactor in direction of its orientation, outline determines the width of the shapes’s outline
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0440turtle. shearfactor[shear=None] ¶Parameters
shear – number [optional]
Set or return the current shearfactor. Shear the turtleshape according to the given shearfactor shear, which is the tangent of the shear angle. Không thay đổi tiêu đề của rùa [hướng di chuyển]. If shear is not given. trả lại shearfactor hiện tại, tôi. e. the tangent of the shear angle, by which lines parallel to the heading of the turtle are sheared
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0441turtle. tilt[angle] ¶Parameters
angle – a number
Rotate the turtleshape by angle from its current tilt-angle, but do not change the turtle’s heading [direction of movement]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0442
angle – a number
Rotate the turtleshape to point in the direction specified by angle, regardless of its current tilt-angle. Do not change the turtle’s heading [direction of movement]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0443
Không dùng nữa kể từ phiên bản 3. 1
turtle. tiltangle[angle=None] ¶Parametersangle – a number [optional]
Set or return the current tilt-angle. If angle is given, rotate the turtleshape to point in the direction specified by angle, regardless of its current tilt-angle. Do not change the turtle’s heading [direction of movement]. If angle is not given. return the current tilt-angle, i. e. the angle between the orientation of the turtleshape and the heading of the turtle [its direction of movement]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0444turtle. shapetransform[t11=None , t12=None , t21=None , t22=None] ¶Parameters
t11 – a number [optional]
t12 – a number [optional]
t21 – a number [optional]
t12 – a number [optional]
Set or return the current transformation matrix of the turtle shape
If none of the matrix elements are given, return the transformation matrix as a tuple of 4 elements. Otherwise set the given elements and transform the turtleshape according to the matrix consisting of first row t11, t12 and second row t21, t22. The determinant t11 * t22 - t12 * t21 must not be zero, otherwise an error is raised. Modify stretchfactor, shearfactor and tiltangle according to the given matrix
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0445turtle. get_shapepoly[] ¶
Return the current shape polygon as tuple of coordinate pairs. This can be used to define a new shape or components of a compound shape
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0446
Using events¶
turtle. title[fun , btn=1 , add=None] Parametersfun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas
btn – number of the mouse-button, defaults to 1 [left mouse button]
add –
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246 or>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1247 – if>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246, a new binding will be added, otherwise it will replace a former binding
Bind fun to mouse-click events on this turtle. If fun is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, existing bindings are removed. Example for the anonymous turtle, i. e. the procedural way
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0447turtle. onrelease[fun , btn=1 , add=None] ¶Parameters
fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas
btn – number of the mouse-button, defaults to 1 [left mouse button]
add –
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246 or>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1247 – if>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246, a new binding will be added, otherwise it will replace a former binding
Bind fun to mouse-button-release events on this turtle. If fun is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, existing bindings are removed
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0448turtle. ondrag[fun , btn=1 , add=None] ¶Parameters
fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas
btn – number of the mouse-button, defaults to 1 [left mouse button]
add –
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246 or>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1247 – if>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246, a new binding will be added, otherwise it will replace a former binding
Bind fun to mouse-move events on this turtle. If fun is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, existing bindings are removed
Remark. Every sequence of mouse-move-events on a turtle is preceded by a mouse-click event on that turtle
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0449
Subsequently, clicking and dragging the Turtle will move it across the screen thereby producing handdrawings [if pen is down]
Special Turtle methods¶
turtle. begin_poly[] ¶Start recording the vertices of a polygon. Current turtle position is first vertex of polygon
turtle. end_poly[] ¶Stop recording the vertices of a polygon. Current turtle position is last vertex of polygon. This will be connected with the first vertex
turtle. get_poly[] ¶Return the last recorded polygon
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0490turtle. clone[] ¶
Create and return a clone of the turtle with same position, heading and turtle properties
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0491turtle. getturtle[] ¶ turtle. getpen[] ¶
Return the Turtle object itself. Only reasonable use. as a function to return the “anonymous turtle”
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0492turtle. getscreen[] ¶
Return the
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.05 object the turtle is drawing on. TurtleScreen methods can then be called for that object
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0493turtle. setundobuffer[size] ¶Parameters
size – an integer or
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229
Set or disable undobuffer. If size is an integer, an empty undobuffer of given size is installed. size gives the maximum number of turtle actions that can be undone by the
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0432 method/function. If size is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, the undobuffer is disabled
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0494turtle. undobufferentries[] ¶
Return number of entries in the undobuffer
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0495
Compound shapes¶
To use compound turtle shapes, which consist of several polygons of different color, you must use the helper class
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04002 explicitly as described below
Create an empty Shape object of type “compound”
Add as many components to this object as desired, using the
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4003 methodFor example
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
496Now add the Shape to the Screen’s shapelist and use it
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
497
Ghi chú
The
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04002 class is used internally by the
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01211 method in different ways. The application programmer has to deal with the Shape class only when using compound shapes like shown above
Methods of TurtleScreen/Screen and corresponding functions¶
Most of the examples in this section refer to a TurtleScreen instance called
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04006
Window control¶
turtle. bgcolor[*args] ¶Parametersargs – a color string or three numbers in the range 0. colormode or a 3-tuple of such numbers
Set or return background color of the TurtleScreen
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0498turtle. bgpic[picname=None] ¶Parameters
picname – a string, name of a gif-file or
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04007, or
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229
Set background image or return name of current backgroundimage. If picname is a filename, set the corresponding image as background. If picname is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04007, delete background image, if present. If picname is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, return the filename of the current backgroundimage
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0499turtle. xóa[]
Ghi chú
This TurtleScreen method is available as a global function only under the name
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04011. The global function
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04012 is a different one derived from the Turtle method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04012turtle. clearscreen[] ¶
Delete all drawings and all turtles from the TurtleScreen. Đặt lại TurtleScreen hiện đang trống về trạng thái ban đầu. nền trắng, không có hình nền, không có ràng buộc sự kiện và theo dõi trên
rùa. đặt lại[]Ghi chú
This TurtleScreen method is available as a global function only under the name
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04014. Hàm toàn cục
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04015 là một hàm khác bắt nguồn từ phương thức Rùa
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04015turtle. resetscreen[] ¶
Reset all Turtles on the Screen to their initial state
turtle. screensize[canvwidth=None , canvheight=None , bg=None] ¶Parameterscanvwidth – positive integer, new width of canvas in pixels
canvheight – positive integer, new height of canvas in pixels
bg – colorstring or color-tuple, new background color
If no arguments are given, return current [canvaswidth, canvasheight]. Else resize the canvas the turtles are drawing on. Do not alter the drawing window. To observe hidden parts of the canvas, use the scrollbars. With this method, one can make visible those parts of a drawing which were outside the canvas before
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0500
e. g. to search for an erroneously escaped turtle ;-]
turtle. setworldcoordinates[llx , lly , urx , ury] ¶Parametersllx – a number, x-coordinate of lower left corner of canvas
lly – a number, y-coordinate of lower left corner of canvas
urx – a number, x-coordinate of upper right corner of canvas
ury – a number, y-coordinate of upper right corner of canvas
Set up user-defined coordinate system and switch to mode “world” if necessary. This performs a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04017. If mode “world” is already active, all drawings are redrawn according to the new coordinates
ATTENTION. in user-defined coordinate systems angles may appear distorted
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0501
Animation control¶
turtle. delay[delay=None] ¶Parametersdelay – positive integer
Set or return the drawing delay in milliseconds. [This is approximately the time interval between two consecutive canvas updates. ] The longer the drawing delay, the slower the animation
Optional argument
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0502turtle. tracer[n=None , delay=None] ¶Parameters
n – nonnegative integer
delay – nonnegative integer
Turn turtle animation on/off and set delay for update drawings. If n is given, only each n-th regular screen update is really performed. [Can be used to accelerate the drawing of complex graphics. ] When called without arguments, returns the currently stored value of n. Second argument sets delay value [see
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0495]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0503turtle. update[] ¶
Perform a TurtleScreen update. To be used when tracer is turned off
See also the RawTurtle/Turtle method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0433
Using screen events¶
turtle. listen[xdummy=None , ydummy=None] ¶Set focus on TurtleScreen [in order to collect key-events]. Dummy arguments are provided in order to be able to pass
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0498 to the title methodturtle. onkey[fun , key] ¶ turtle. onkeyrelease[fun , key] ¶Parameters
fun – a function with no arguments or
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229key – a string. key [e. g. “a”] or key-symbol [e. g. “space”]
Bind fun to key-release event of key. If fun is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, event bindings are removed. Remark. in order to be able to register key-events, TurtleScreen must have the focus. [See method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0498. ]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0504turtle. onkeypress[fun , key=None] ¶Parameters
fun – a function with no arguments or
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229key – a string. key [e. g. “a”] or key-symbol [e. g. “space”]
Bind fun to key-press event of key if key is given, or to any key-press-event if no key is given. Remark. in order to be able to register key-events, TurtleScreen must have focus. [See method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0498. ]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0505turtle. title[fun , btn=1 , add=None] ¶ turtle. onscreenclick[fun , btn=1 , add=None] ¶Parameters
fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas
btn – number of the mouse-button, defaults to 1 [left mouse button]
add –
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246 or>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1247 – if>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246, a new binding will be added, otherwise it will replace a former binding
Bind fun to mouse-click events on this screen. If fun is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229, existing bindings are removed
Example for a TurtleScreen instance named
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04006 and a Turtle instance named
>>> turtle.setheading[90] >>> turtle.heading[] 90.08
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0506
Ghi chú
This TurtleScreen method is available as a global function only under the name
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04032. The global function
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04033 is another one derived from the Turtle method
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04033turtle. ontimer[fun , t=0] ¶Parameters
fun – a function with no arguments
t – a number >= 0
Install a timer that calls fun after t milliseconds
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0507turtle. mainloop[] ¶ turtle. done[] ¶
Starts event loop - calling Tkinter’s mainloop function. Must be the last statement in a turtle graphics program. Must not be used if a script is run from within IDLE in -n mode [No subprocess] - for interactive use of turtle graphics
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0508
Input methods¶
turtle. textinput[title , prompt] ¶Parameterstitle – string
prompt – string
Pop up a dialog window for input of a string. Parameter title is the title of the dialog window, prompt is a text mostly describing what information to input. Return the string input. If the dialog is canceled, return
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0509turtle. numinput[title , prompt , default=None , minval=None , maxval=None] ¶Parameters
title – string
prompt – string
default – number [optional]
minval – number [optional]
maxval – number [optional]
Bật lên một cửa sổ hộp thoại để nhập số. tiêu đề là tiêu đề của cửa sổ hộp thoại, dấu nhắc là văn bản chủ yếu mô tả thông tin số cần nhập. default. default value, minval. minimum value for input, maxval. maximum value for input. The number input must be in the range minval . maxval nếu chúng được đưa ra. Nếu không, một gợi ý sẽ được đưa ra và hộp thoại vẫn mở để chỉnh sửa. Trả về số đầu vào. Nếu hộp thoại bị hủy, hãy trả lại
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0510
Cài đặt và phương pháp đặc biệt¶
rùa. chế độ[chế độ=Không có]¶Parameterschế độ – một trong các chuỗi “tiêu chuẩn”, “logo” hoặc “thế giới”
Đặt chế độ rùa [“tiêu chuẩn”, “logo” hoặc “thế giới”] và thực hiện đặt lại. Nếu chế độ không được cung cấp, chế độ hiện tại được trả về
Chế độ “tiêu chuẩn” tương thích với
>>> turtle.setheading[90] >>> turtle.heading[] 90.08 cũ. Chế độ “logo” tương thích với hầu hết đồ họa Logo rùa. Chế độ “thế giới” sử dụng “tọa độ thế giới” do người dùng xác định. Chú ý. ở chế độ này, các góc có vẻ bị biến dạng nếu tỷ lệ đơn vị của
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04038 không bằng 1
Mode
tiêu đề rùa ban đầu
góc dương
"Tiêu chuẩn"
bên phải [phía đông]
ngược chiều kim đồng hồ
"Logo"
hướng lên trên [bắc]
theo chiều kim đồng hồ
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0511rùa. chế độ màu[cmode=Không có]¶Parameters
cmode – một trong các giá trị 1. 0 hoặc 255
Trả về colormode hoặc đặt thành 1. 0 hoặc 255. Sau đó, các giá trị r, g, b của bộ ba màu phải nằm trong khoảng 0. *chế độ*
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0512rùa. getcanvas[] ¶
Trả lại Canvas của TurtleScreen này. Hữu ích cho những người trong cuộc biết phải làm gì với Tkinter Canvas
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0513
Trả về danh sách tên của tất cả các hình con rùa hiện có
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0514rùa. register_shape[tên , hình . =None]¶turtle.thêm hình dạng[tên , hình dạng=None]¶
Có ba cách khác nhau để gọi chức năng này
tên là tên của tệp gif và hình dạng là
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229. Cài đặt hình ảnh tương ứng>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
515Ghi chú
Các hình ảnh không xoay khi xoay rùa nên không hiển thị tiêu đề của rùa
tên là một chuỗi tùy ý và hình dạng là một bộ các cặp tọa độ. Cài đặt hình đa giác tương ứng
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
516tên là một chuỗi tùy ý và hình dạng là một đối tượng [hợp chất]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4002. Cài đặt hình ghép tương ứng
Add a turtle shape to TurtleScreen’s shapelist. Only thusly registered shapes can be used by issuing the command
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04041turtle. turtles[] ¶
Return the list of turtles on the screen
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0517turtle. window_height[] ¶
Return the height of the turtle window
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0518turtle. window_width[] ¶
Return the width of the turtle window
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0519
Methods specific to Screen, not inherited from TurtleScreen¶
turtle. bye[] ¶Shut the turtlegraphics window
turtle. exit title[] ¶Bind
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01218 method to mouse clicks on the Screen
If the value “using_IDLE” in the configuration dictionary is
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01247 [default value], also enter mainloop. Remark. If IDLE with the
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.03 switch [no subprocess] is used, this value should be set to
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01246 in
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04046. In this case IDLE’s own mainloop is active also for the client scriptturtle. setup[width=_CFG['width'] , height=_CFG['height'] , startx=_CFG['leftright'] , starty=_CFG['topbottom']] ¶
Set the size and position of the main window. Default values of arguments are stored in the configuration dictionary and can be changed via a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04046 fileParameters
width – if an integer, a size in pixels, if a float, a fraction of the screen; default is 50% of screen
height – if an integer, the height in pixels, if a float, a fraction of the screen; default is 75% of screen
startx – if positive, starting position in pixels from the left edge of the screen, if negative from the right edge, if
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229, center window horizontallystarty – if positive, starting position in pixels from the top edge of the screen, if negative from the bottom edge, if
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1229, center window vertically
>>> turtle.setheading[90] >>> turtle.heading[] 90.00turtle. title[titlestring] ¶Parameters
titlestring – a string that is shown in the titlebar of the turtle graphics window
Set title of turtle window to titlestring
>>> turtle.setheading[90] >>> turtle.heading[] 90.01
Public classes¶
class turtle. RawTurtle[canvas] ¶ class turtle. RawPen[canvas] ¶Parameterscanvas – a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.06, a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.07 or a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.05
Create a turtle. The turtle has all methods described above as “methods of Turtle/RawTurtle”
class turtle. Turtle ¶Subclass of RawTurtle, has the same interface but draws on a default
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0407 object created automatically when needed for the first timeclass turtle. TurtleScreen[cv] ¶Parameters
cv – a
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.06
Provides screen oriented methods like
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04055 etc. that are described aboveclass turtle. Screen ¶
Subclass of TurtleScreen, with four methods added .
class turtle. ScrolledCanvas[master] ¶Parametersmaster – some Tkinter widget to contain the ScrolledCanvas, i. e. a Tkinter-canvas with scrollbars added
Được sử dụng bởi lớp Screen, do đó tự động cung cấp ScrolledCanvas làm sân chơi cho rùa
lớp rùa. Shape[type_ , data] ¶Parameterstype_ – one of the strings “polygon”, “image”, “compound”
Hình dạng mô hình cấu trúc dữ liệu. Cặp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04056 phải tuân theo thông số kỹ thuật này
loại hình_
dữ liệu
“đa giác”
một đa giác-tuple, tôi. e. một bộ các cặp tọa độ
"hình ảnh"
một hình ảnh [ở dạng này chỉ được sử dụng trong nội bộ. ]
"hợp chất"
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01229 [một hình ghép phải được dựng bằng phương pháp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04003]thêm thành phần[nhiều , điền, outline=None]¶Parameters
poly – một đa giác, i. e. một bộ các cặp số
tô màu – một màu poly sẽ được lấp đầy
phác thảo - một màu cho đường viền của poly [nếu có]
Thí dụ
>>> turtle.setheading[90] >>> turtle.heading[] 90.02
Xem Các hình ghép .
lớp rùa. Vec2D[x , y]¶Lớp vectơ hai chiều, được sử dụng làm lớp trợ giúp để triển khai đồ họa con rùa. Cũng có thể hữu ích cho các chương trình đồ họa rùa. Xuất phát từ bộ, vì vậy một vectơ là một bộ
Cung cấp [cho vectơ a, b, số k]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4059 vector additionPhép trừ véc tơ
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4060>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4061 sản phẩm bên trongPhép nhân
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4062 và>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4063 với vô hướng>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4064 giá trị tuyệt đối của aVòng quay
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4065
Trợ giúp và cấu hình¶
Cách sử dụng trợ giúp¶
Các phương thức công khai của các lớp Màn hình và Rùa được ghi lại rộng rãi thông qua các tài liệu. Vì vậy, chúng có thể được sử dụng làm trợ giúp trực tuyến thông qua các tiện ích trợ giúp của Python
Khi sử dụng IDLE, chú giải công cụ hiển thị chữ ký và dòng đầu tiên của chuỗi tài liệu được nhập trong lệnh gọi hàm/phương thức
Gọi
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4066 trên các phương thức hoặc chức năng sẽ hiển thị các chuỗi tài liệu>>> turtle.setheading[90] >>> turtle.heading[] 90.0
3Các tài liệu của các chức năng bắt nguồn từ các phương thức có dạng được sửa đổi
>>> turtle.setheading[90] >>> turtle.heading[] 90.0
4
Các chuỗi tài liệu đã sửa đổi này được tạo tự động cùng với các định nghĩa hàm bắt nguồn từ các phương thức tại thời điểm nhập
Dịch tài liệu sang các ngôn ngữ khác nhau¶
Có một tiện ích để tạo một từ điển, các khóa là tên phương thức và giá trị của chúng là chuỗi tài liệu của các phương thức công khai của các lớp Màn hình và Con rùa
rùa. write_docstringdict[tên tệp=']¶Parameterstên tệp - một chuỗi, được sử dụng làm tên tệp
Tạo và viết từ điển chuỗi tài liệu vào tập lệnh Python với tên tệp đã cho. Chức năng này phải được gọi rõ ràng [nó không được sử dụng bởi các lớp đồ họa con rùa]. Từ điển chuỗi tài liệu sẽ được ghi vào tập lệnh Python
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04067. Nó được dùng làm khuôn mẫu để dịch các chuỗi tài liệu sang các ngôn ngữ khác nhau
Nếu bạn [hoặc học sinh của bạn] muốn sử dụng
>>> turtle.setheading[90] >>> turtle.heading[] 90.08 với sự trợ giúp trực tuyến bằng ngôn ngữ mẹ đẻ của mình, bạn phải dịch các chuỗi tài liệu và lưu tệp kết quả dưới dạng e. g.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04069
Nếu bạn có một mục thích hợp trong tệp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04046 của mình, từ điển này sẽ được đọc tại thời điểm nhập và sẽ thay thế các chuỗi tài liệu gốc bằng tiếng Anh
Tại thời điểm viết bài này, có các từ điển chuỗi tài liệu bằng tiếng Đức và tiếng Ý. [Các yêu cầu vui lòng tham khảo @ aon . tại. ]
Cách định cấu hình Màn hình và Rùa¶
Cấu hình mặc định tích hợp bắt chước giao diện và hành vi của mô-đun rùa cũ để duy trì khả năng tương thích tốt nhất có thể với nó
Nếu bạn muốn sử dụng một cấu hình khác phản ánh tốt hơn các tính năng của mô-đun này hoặc phù hợp hơn với nhu cầu của bạn, hãy. g. để sử dụng trong lớp học, bạn có thể chuẩn bị tệp cấu hình
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04046 sẽ được đọc tại thời điểm nhập và sửa đổi cấu hình theo cài đặt của nó
Cấu hình tích hợp sẽ tương ứng với con rùa sau. cfg
>>> turtle.setheading[90] >>> turtle.heading[] 90.05
Giải thích ngắn về các mục đã chọn
Bốn dòng đầu tiên tương ứng với các đối số của phương thức
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4072Dòng 5 và 6 tương ứng với các đối số của phương thức
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4073hình dạng có thể là bất kỳ hình dạng tích hợp nào, e. g. mũi tên, rùa, vv. Để biết thêm thông tin, hãy thử
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4074Nếu bạn muốn sử dụng không tô màu [tôi. e. làm cho con rùa trong suốt], bạn phải viết
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4075 [nhưng tất cả các chuỗi không trống không được có dấu ngoặc kép trong tệp cfg]Nếu bạn muốn phản ánh trạng thái của rùa, bạn phải sử dụng
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4076Nếu bạn đặt e. g.
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4077 docstringdict>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4078 sẽ được tải vào thời điểm nhập [nếu xuất hiện trên đường dẫn nhập, e. g. trong cùng thư mục với>>> turtle.setheading[90] >>> turtle.heading[] 90.0
8]Các mục exampleturtle và examplescreen xác định tên của các đối tượng này khi chúng xuất hiện trong chuỗi tài liệu. Việc chuyển đổi method-docstrings thành function-docstrings sẽ xóa những tên này khỏi docstrings
sử dụng_IDLE. Đặt giá trị này thành
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246 nếu bạn thường xuyên làm việc với IDLE và công tắc>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
3 của nó [“không có quy trình con”]. Điều này sẽ ngăn>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1219 vào vòng lặp chính
Có thể có một tệp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04046 trong thư mục lưu trữ
>>> turtle.setheading[90] >>> turtle.heading[] 90.08 và một tệp bổ sung trong thư mục làm việc hiện tại. Cái sau sẽ ghi đè cài đặt của cái đầu tiên
Thư mục
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04085 chứa tệp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04046. Bạn có thể nghiên cứu nó như một ví dụ và xem tác dụng của nó khi chạy các bản demo [tốt nhất là không phải từ bên trong trình xem bản demo]
>>> turtle.heading[]
90.0
>>> turtle.position[]
[0.00,-10.00]
>>> turtle.home[]
>>> turtle.position[]
[0.00,0.00]
>>> turtle.heading[]
0.0
4087 — Tập lệnh demo¶
Gói
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04087 bao gồm một tập lệnh demo. Có thể chạy và xem các tập lệnh này bằng trình xem demo được cung cấp như sau
>>> turtle.setheading[90] >>> turtle.heading[] 90.06
Ngoài ra, bạn có thể chạy các tập lệnh demo riêng lẻ. Ví dụ,
>>> turtle.setheading[90] >>> turtle.heading[] 90.07
Thư mục gói
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.04087 chứa
Trình xem demo ________ 14090 có thể được sử dụng để xem mã nguồn của các tập lệnh và chạy chúng cùng một lúc
Nhiều tập lệnh thể hiện các tính năng khác nhau của mô-đun
>>> turtle.setheading[90] >>> turtle.heading[] 90.0
8. Các ví dụ có thể được truy cập thông qua menu Ví dụ. Chúng cũng có thể được chạy độc lậpTệp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4046 dùng làm ví dụ về cách viết và sử dụng các tệp đó
Các kịch bản demo là
Tên
Sự mô tả
Đặc trưng
thiết kế phụ
mô hình đồ họa rùa cổ điển phức tạp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0496, trì hoãn,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0497
sự hỗn loạn
biểu đồ động lực học Verhulst, cho thấy rằng các tính toán của máy tính đôi khi có thể tạo ra kết quả trái với mong đợi thông thường
tọa độ thế giới
cái đồng hồ
đồng hồ analog hiển thị thời gian của máy tính của bạn
rùa như kim đồng hồ, hẹn giờ
máy pha màu
thử nghiệm với r, g, b
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0479
rừng
3 cây theo chiều rộng
ngẫu nhiên hóa
đường cong fractal
Đường cong Hilbert & Koch
đệ quy
cây bồ đề
dân tộc học [kolams Ấn Độ]
Hệ thống chữ L
min_hanoi
Tháp Hà Nội
Rùa Chữ Nhật dạng đĩa Hà Nội [hình dáng, kích thước]
nim
chơi game nim cổ điển với ba đống gậy trên máy tính
rùa như nimsticks, điều khiển sự kiện [chuột, bàn phím]
sơn
chương trình vẽ siêu tối giản
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0477
hòa bình
tiểu học
rùa. xuất hiện và hoạt hình
hoa hồng
lát gạch định kỳ với diều và phi tiêu
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0429
hành_tinh_và_mặt_trăng
mô phỏng hệ trọng lực
hình ghép,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.01231
round_dance
rùa nhảy múa quay theo cặp theo hướng ngược lại
hình ghép, nhân bản shapesize, tilt, get_shapepoly, cập nhật
sorting_animate
trình diễn trực quan các phương pháp sắp xếp khác nhau
căn chỉnh đơn giản, ngẫu nhiên
cây
cây đầu tiên có chiều rộng [đồ họa] [sử dụng trình tạo]
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0483
two_canvases
Thiết kế đơn giản
rùa trên hai bức tranh
wikipedia
một mẫu từ bài viết trên wikipedia về đồ họa con rùa
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0483,
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0432
yinyang
một ví dụ cơ bản khác
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0427
Chúc vui vẻ
Những thay đổi kể từ Python 2. 6¶
Các phương thức
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4403,>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4404 và>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4405 đã bị loại bỏ. Các phương thức có các tên và chức năng này hiện chỉ khả dụng dưới dạng các phương thức của>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
407. Các chức năng bắt nguồn từ những vẫn có sẵn. [Thực tế đã có trong Python 2. 6 các phương thức này chỉ đơn thuần là bản sao của các phương thức>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
5/>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
407 tương ứng. ]Phương pháp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4409 đã bị loại bỏ. Hành vi của>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
457 và>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
458 đã thay đổi một chút. bây giờ mọi quy trình điền phải được hoàn thành bằng lệnh gọi>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
458Một phương pháp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4413 đã được thêm vào. Nó trả về một giá trị boolean.>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1246 nếu quy trình chiết rót đang được tiến hành, nếu không thì>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1247. Hành vi này tương ứng với lệnh gọi>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4416 không có đối số trong Python 2. 6
Các thay đổi kể từ Python 3. 0¶
Các phương pháp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4417,>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4418 và>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4419 đã được thêm vào. Do đó, hiện có đầy đủ các phép biến đổi tuyến tính thông thường để biến đổi hình con rùa.>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4420 đã được tăng cường chức năng. bây giờ nó có thể được sử dụng để lấy hoặc đặt góc nghiêng.>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4421 không được dùng nữaPhương thức
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4422 đã được thêm vào như một phần bổ sung cho>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4423, trên thực tế, phương thức này liên kết các hành động với sự kiện phát hành khóa. Theo đó, cái sau có bí danh.>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4424Phương pháp
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4425 đã được thêm vào. Vì vậy, khi chỉ làm việc với các đối tượng Màn hình và Rùa, người ta không được nhập thêm>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
1205 nữaHai phương thức nhập liệu đã được thêm vào
>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4427 và>>> turtle.heading[] 90.0 >>> turtle.position[] [0.00,-10.00] >>> turtle.home[] >>> turtle.position[] [0.00,0.00] >>> turtle.heading[] 0.0
4428. Các hộp thoại đầu vào bật lên này và trả về các chuỗi và số tương ứng