2018-07-31 深入了解Python Turtle

自定义坐标系

  • There is a method, setworldcoordinates(), to install a user defined
    coordinate-system for the TurtleScreen.
>>> help(setworldcoordinates)
Help on function setworldcoordinates in module turtle:

setworldcoordinates(llx, lly, urx, ury)
    Set up a user defined coordinate-system.

    Arguments:
    llx -- 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 coodinat-system and switch to mode 'world' if necessary.
    This performs a reset. If mode 'world' is already active,
    all drawings are redrawn according to the new coordinates.

    But ATTENTION: in user-defined coordinatesystems angles may appear
    distorted. (see Screen.mode())

    Example:
    >>> setworldcoordinates(-10,-0.5,50,1.5)
    >>> for _ in range(36):
    ...     left(10)
    ...     forward(0.5)

>>>

以上为自定义坐标系,方便与在turtle中用
注意world模式是否激活
太难理解了

向量

  • The implementation uses a 2-vector class named Vec2D, derived from tuple.
    This class is public, so it can be imported by the application programmer,
    which makes certain types of computations very natural and compact.

本地化

  • If configured appropriately the module reads in docstrings from a docstring
    dictionary in some different language, supplied separately and replaces
    the English ones by those read in. There is a utility function
    write_docstringdict() to write a dictionary with the original (English)
    docstrings to disc, so it can serve as a template for translations.

其他奇思妙想

  • Behind the scenes there are some features included with possible
    extensions in mind. These will be commented and documented elsewhere.

向量运算


new魔术方法与cls参数什么意思呢?

getnewargs

待理解

费解

代表对象自身的self参数和类自身的cls参数

staticmethod classmethod

tkinter的显示对象列表displayobjectlist

image.png

用捕捉异常的方法设置标志变量

异常与标志变量

利用百分号格式化字符串

单击乌龟时候的事件冒泡顺序

异常类导入的时候就会调用

C:\Users\langxianmeng>python
Python 3.6.4 
Type "help", "copyright", "credits" or "license" for more information.
>>> from turtle import *
哈哈哈,挂了吧!
>>>

turtle screen的mode

苹果系统强制窗口在最前

列表切片的写法

turtle不同的坐标模式

坐标系调整为processing

from turtle import *

screen = Screen()
screen.setup(300, 400)
shape('circle')
shapesize(4)
screen.setworldcoordinates(0,window_height(),window_width(),0)
goto(0, 0)
done()

onscreenclick

初始化函数

牛逼

牛逼的等效

Pen  = Turtle
done = mainloop
getpen = getturtle
   fd = forward
    bk = back
    backward = back
    rt = right
    lt = left
    position = pos
    setpos = goto
    setposition = goto
    seth = setheading

竟然不报错

image.png

你可能感兴趣的:(2018-07-31 深入了解Python Turtle)