当前位置: 首页>>代码示例>>Python>>正文


Python turtle.Screen方法代码示例

本文整理汇总了Python中turtle.Screen方法的典型用法代码示例。如果您正苦于以下问题:Python turtle.Screen方法的具体用法?Python turtle.Screen怎么用?Python turtle.Screen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在turtle的用法示例。


在下文中一共展示了turtle.Screen方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def main():
    global screen, red, green, blue
    screen = Screen()
    screen.delay(0)
    screen.setworldcoordinates(-1, -0.3, 3, 1.3)

    red = ColorTurtle(0, .5)
    green = ColorTurtle(1, .5)
    blue = ColorTurtle(2, .5)
    setbgcolor()

    writer = Turtle()
    writer.ht()
    writer.pu()
    writer.goto(1,1.15)
    writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
    return "EVENTLOOP" 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:colormixer.py

示例2: main

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def main():
    myTurtle = turtle.Turtle()
    myTurtle.speed(0)  # adjust the drawing speed here
    myWin = turtle.Screen()
    
    size = 300
    # 3 points of the first triangle based on [x,y] coordinates
    myPoints = [[0, 0], [0, size], [size, size], [size, 0]]
    
    degree = 1  # Vary the degree of complexity here
    
    # first call of the recursive function
    sierpinski(myPoints, degree, myTurtle)

    myTurtle.hideturtle()  # hide the turtle cursor after drawing is completed
    myWin.exitonclick()  # Exit program when user click on window 
开发者ID:furas,项目名称:python-examples,代码行数:18,代码来源:main.py

示例3: main

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def main():
    s = Screen()
    s.bgcolor("black")
    p=Turtle()
    p.speed(0)
    p.hideturtle()
    p.pencolor("red")
    p.pensize(3)

    s.tracer(36,0)

    at = clock()
    mn_eck(p, 36, 19)
    et = clock()
    z1 = et-at

    sleep(1)

    at = clock()
    while any([t.undobufferentries() for t in s.turtles()]):
        for t in s.turtles():
            t.undo()
    et = clock()
    return "runtime: %.3f sec" % (z1+et-at) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:26,代码来源:wikipedia.py

示例4: __init__

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def __init__(self, x=0, y=0, dest=None):
        self.t = turtle.Turtle()
        self.t.speed(0)
        
        self.t.up()
        self.t.goto(x, y)
        self.t.down()
        
        if dest is None:
            # use start point as destination point
            self.destination(x, y)
        else:
            self.destination(*dest)
            
        # it is needed by `move` to execute `ontimer`
        self.screen = turtle.Screen()

        # start moving
        self.move() 
开发者ID:furas,项目名称:python-examples,代码行数:21,代码来源:turtle-followed-mouse.py

示例5: __init__

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def __init__(self, pos, dest=None):
        '''create and initiate moth'''
        
        # define turtle 
        self.t = turtle.Turtle()
        self.t.speed(0)

        # it is needed to execute `ontimer`
        self.screen = turtle.Screen()
        
        # remember destination
        self.dest = dest

        # at start it is not fly
        self.is_flying = False        

        # move to start position 
        #(it will use self.dest so it has to be after `self.dest = dest`)
        self.move(pos)
        
        # if destination is set then fly to it
        # (currently it is in `move()`)
        #if self.dest is not None:
        #    self.move_to_light(self.dest) 
开发者ID:furas,项目名称:python-examples,代码行数:26,代码来源:turtle-moth-light.py

示例6: makeGraphFrame

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def makeGraphFrame(self, root):
        turtle._Screen._root = root
        self.canvwidth = 1000
        self.canvheight = 800
        turtle._Screen._canvas = self._canvas = canvas = turtle.ScrolledCanvas(
                root, 800, 600, self.canvwidth, self.canvheight)
        canvas.adjustScrolls()
        canvas._rootwindow.bind('<Configure>', self.onResize)
        canvas._canvas['borderwidth'] = 0

        self.screen = _s_ = turtle.Screen()
        turtle.TurtleScreen.__init__(_s_, _s_._canvas)
        self.scanvas = _s_._canvas
        turtle.RawTurtle.screens = [_s_]
        return canvas 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:17,代码来源:__main__.py

示例7: main

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def main():
    mainscreen = turtle.Screen()
    mainscreen.mode("standard")
    mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
    nim = Nim(mainscreen)
    return "EVENTLOOP" 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:nim.py

示例8: visualize

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def visualize(lines):
    import turtle
    wn = turtle.Screen()
    t = turtle.Turtle()
    t.speed(0)
    t.pencolor('red')
    t.pd()
    for i in range(0,len(lines)):
        for p in lines[i]:
            t.goto(p[0]*640/1024-320,-(p[1]*640/1024-320))
            t.pencolor('black')
        t.pencolor('red')
    turtle.mainloop() 
开发者ID:LingDong-,项目名称:linedraw,代码行数:15,代码来源:strokesort.py

示例9: square

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def square():
    win = turtle.Screen()
    win.bgcolor("white")
    jack = turtle.Turtle()
    for x in range(1,5):
              jack.forward(100)
              jack.right(90)
    win.exitonclick() 
开发者ID:AsciiKay,项目名称:Beginners-Python-Examples,代码行数:10,代码来源:squareTurtle.py

示例10: Turtle_Mini_Project_KC

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def Turtle_Mini_Project_KC():
    window = turtle.Screen()
    window.bgcolor("white")
    brad = turtle.Turtle()
    brad.shape("turtle")
    brad.color("blue")
    brad.speed(1)

    draw_K(brad)
    draw_C(brad)
    
    window.exitonclick() 
开发者ID:MurphyWan,项目名称:Python-first-Practice,代码行数:14,代码来源:Turtle_Mini_Project_KC.py

示例11: test_turtle_launch

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def test_turtle_launch(tmpdir):
    """Test turtle scripts running in the same kernel."""
    # Command to start the kernel
    cmd = "from spyder_kernels.console import start; start.main()"

    with setup_kernel(cmd) as client:
        # Remove all variables
        client.execute("%reset -f")
        client.get_shell_msg(block=True, timeout=TIMEOUT)

        # Write turtle code to a file
        code = """
import turtle
wn=turtle.Screen()
wn.bgcolor("lightgreen")
tess = turtle.Turtle() # Create tess and set some attributes
tess.color("hotpink")
tess.pensize(5)

tess.forward(80) # Make tess draw equilateral triangle
tess.left(120)
tess.forward(80)
tess.left(120)
tess.forward(80)
tess.left(120) # Complete the triangle

turtle.bye()
"""
        p = tmpdir.join("turtle-test.py")
        p.write(code)

        # Run code
        client.execute("runfile(r'{}')".format(to_text_string(p)))
        client.get_shell_msg(block=True, timeout=TIMEOUT)

        # Verify that the `tess` variable is defined
        client.inspect('tess')
        msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
        content = msg['content']
        assert content['found']

        # Write turtle code to a file
        code = code + "a = 10"

        p = tmpdir.join("turtle-test1.py")
        p.write(code)

        # Run code again
        client.execute("runfile(r'{}')".format(to_text_string(p)))
        client.get_shell_msg(block=True, timeout=TIMEOUT)

        # Verify that the `a` variable is defined
        client.inspect('a')
        msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
        content = msg['content']
        assert content['found'] 
开发者ID:spyder-ide,项目名称:spyder-kernels,代码行数:58,代码来源:test_console_kernel.py

示例12: __init__

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def __init__(self):

        self.done = False
        self.reward = 0
        self.hit, self.miss = 0, 0

        # Setup Background

        self.win = t.Screen()
        self.win.title('Paddle')
        self.win.bgcolor('black')
        self.win.setup(width=600, height=600)
        self.win.tracer(0)

        # Paddle

        self.paddle = t.Turtle()
        self.paddle.speed(0)
        self.paddle.shape('square')
        self.paddle.shapesize(stretch_wid=1, stretch_len=5)
        self.paddle.color('white')
        self.paddle.penup()
        self.paddle.goto(0, -275)

        # Ball

        self.ball = t.Turtle()
        self.ball.speed(0)
        self.ball.shape('circle')
        self.ball.color('red')
        self.ball.penup()
        self.ball.goto(0, 100)
        self.ball.dx = 3
        self.ball.dy = -3

        # Score

        self.score = t.Turtle()
        self.score.speed(0)
        self.score.color('white')
        self.score.penup()
        self.score.hideturtle()
        self.score.goto(0, 250)
        self.score.write("Hit: {}   Missed: {}".format(self.hit, self.miss), align='center', font=('Courier', 24, 'normal'))

        # -------------------- Keyboard control ----------------------

        self.win.listen()
        self.win.onkey(self.paddle_right, 'Right')
        self.win.onkey(self.paddle_left, 'Left')

    # Paddle movement 
开发者ID:shivaverma,项目名称:Orbit,代码行数:54,代码来源:paddle.py

示例13: __init__

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import Screen [as 别名]
def __init__(self):

        self.screen_width = 900
        self.screen_length = 400
        self.done = False
        self.hit, self.miss = 0, 0
        self.scorecount = 0
        self.reward = 0
        self.triggered = False
        self.count = 20
        self.direction = 1
        self.speed = 5
        self.up_down_count = 20
        self.t_rex_speed = 5
        self.obs_size = 4
        self.counter = 100

        self.start = -180
        self.end = -90
        self.diff = (self.end - self.start) / (self.obs_size - 1)

        # self.color = ['orange', 'red', 'blue', 'green', 'yellow', 'cyan', 'purple', 'magenta']
        self.color = ['red', 'red', 'red', 'red', 'red', 'red', 'red', 'red']
        self.obs_height = [self.start + self.diff * i for i in range(self.obs_size)]
        self.obs = [turtle.Turtle() for i in range((self.obs_size * 3) // 2)]

        self.initializeObs()

        self.done = 0
        self.reward = 0

        # Set up Background
        self.win = turtle.Screen()
        self.win.title('T rex')
        self.win.bgcolor('black')
        self.win.setup(width=self.screen_width, height=self.screen_length)
        self.win.tracer(0)

        # T rex config
        self.t_rex = turtle.Turtle()
        self.inializeTrext()

        # Obstacle config
        self.obstacle_speed = -3

        self.win.listen()
        self.win.onkey(self.triggerjump, 'space')

        self.score = turtle.Turtle()
        self.score.speed(0)
        self.score.color('white')
        self.score.penup()
        self.score.hideturtle()
        self.score.goto(0, 160)
        self.score.write("Score : {}".format(self.scorecount), align='center', font=('Courier', 24, 'normal')) 
开发者ID:shivaverma,项目名称:Orbit,代码行数:57,代码来源:jump.py


注:本文中的turtle.Screen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。