猫史档案馆


【Python作品分享】中文海龟画图编辑器2.0【求助帖】

用户:炸图监管者炸图监管者查看:4 回复:1 评论:4 创建时间:2021-05-12T13:03:21


【作品展示】

center_image

 

【作品介绍】

谁能改成一步运行

 

【作品源代码】

import turtle


print('欢迎使用中文海龟画图编辑器')
print('支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度[1-10] 移动 移动X 移动Y 清除 归位 重置     输入帮助获取')
while True:
    a = input('>>>')
    if (a == '画板'):
        turtle.Pen()
    if (a == '粗细'):
        cu = input('粗细:')
        turtle.pensize(cu)
    if (a == '颜色'):
        e = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:')
        if (e == '红'):
            turtle.color('red')
        if (e == '绿'):
            turtle.color('green')
        if (e == '蓝'):
            turtle.color('blue')
        if (e == '橙'):
            turtle.color('orang')
        if (e == '黄'):
            turtle.color('yellow')
        if (e == '黑'):
            turtle.color('black')
        if (e == '白'):
            turtle.color('white')
        if (e == '粉'):
            turtle.color('pink')
        if (e == '紫'):
            turtle.color('purple')
    if (a == '走路'):
        bu = int(input('步数:'))
        turtle.forward(bu)
        bu = 0
    if (a == '旋转'):
        zhuan = int(input('度数:'))
        turtle.left(zhuan)
    if (a == '底色'):
        s = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:')
        if (s == '红'):
            turtle.bgcolor('red')
        if (s == '绿'):
            turtle.bgcolor('green')
        if (s == '蓝'):
            turtle.bgcolor('blue')
        if (s == '橙'):
            turtle.bgcolor('orang')
        if (s == '黄'):
            turtle.bgcolor('yellow')
        if (s == '黑'):
            turtle.bgcolor('black')
        if (s == '白'):
            turtle.bgcolor('white')
        if (s == '粉'):
            turtle.bgcolor('pink')
        if (s == '紫'):
            turtle.bgcolor('purple')
    if (a == '帮助'):
        print('支持语法:颜色 底色 移动 旋转 画板 粗细')
    if (a == '速度[1-10]'):
        sudu = int(input('速度:'))
        turtle.speed(sudu)
    if (a == '抬笔'):
        turtle.penup()
    if (a == '落笔'):
        turtle.pendown()
    if (a == '隐藏'):
        turtle.hideturtle()
    if (a == '移动'):
        yiX = int(input('X:'))
        yiY = int(input('Y:'))
        turtle.goto(yiX, yiY)
    if (a == '移动X'):
        XXX = int(input('X:'))
        turtle.setx(XXX)
    if (a == '移动Y'):
        YYY = int(input('Y:'))
        turtle.sety(YYY)
    if (a == '清除'):
        turtle.clear()
    if (a == '归位'):
        turtle.home()
    if (a == '重置'):
        turtle.reset()
    if (a == '帮助'):
        print('支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度[1-10] 移动 移动X 移动Y 清除 归位 重置')

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
伴雪纷飞伴雪纷飞

是这个意思吗?(码起来不容易...

import turtle
def run(run_fanc):
    print('start run')
    print('list ran_fanc function is  '+str(run_fanc))
    for i in run_fanc:
        print(i)
        i()


print('欢迎使用中文海龟画图编辑器')
print(
    '支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度[1-10] 移动 移动X 移动Y 清除 归位 重置     输入帮助获取')
fanc=[]
while True:

    a = input('>>>')
    if (a == '运行'):
        run(fanc)
    if (a == '画板'):
        fanc.append(turtle.Pen)
    if (a == '粗细'):
        def f1():
            cu = input('粗细:')
            turtle.pensize(cu)
        fanc.append(f1)

    if (a == '颜色'):
        def f2():
            e = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:>>>')
            if (e == '红'):
                turtle.color('red')
            if (e == '绿'):
                turtle.color('green')
            if (e == '蓝'):
                turtle.color('blue')
            if (e == '橙'):
                turtle.color('orang')
            if (e == '黄'):
                turtle.color('yellow')
            if (e == '黑'):
                turtle.color('black')
            if (e == '白'):
                turtle.color('white')
            if (e == '粉'):
                turtle.color('pink')
            if (e == '紫'):
                turtle.color('purple')
        fanc.append(f2)
    if (a == '走路'):
        def f3():
            bu = int(input('步数:'))
            turtle.forward(bu)
            bu = 0
        global bu
        fanc.append(f3)
    if (a == '旋转'):
        def f4():
            zhuan = int(input('度数:'))
            turtle.left(zhuan)
        fanc.append(f4)
    if (a == '底色'):
        def f5():
            s = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:>>>')
            if (s == '红'):
                turtle.bgcolor('red')
            if (s == '绿'):
                turtle.bgcolor('green')
            if (s == '蓝'):
                turtle.bgcolor('blue')
            if (s == '橙'):
                turtle.bgcolor('orang')
            if (s == '黄'):
                turtle.bgcolor('yellow')
            if (s == '黑'):
                turtle.bgcolor('black')
            if (s == '白'):
                turtle.bgcolor('white')
            if (s == '粉'):
                turtle.bgcolor('pink')
            if (s == '紫'):
                turtle.bgcolor('purple')
        fanc.append(f5)
    if (a == '帮助'):
        def f6():
            print('支持语法:颜色 底色 移动 旋转 画板 粗细')
        fanc.append(f6)
    if (a == '速度[1-10]'):
        def f7():
            sudu = int(input('速度:'))
            turtle.speed(sudu)
        fanc.append(f7)
    if (a == '抬笔'):
        fanc.append(turtle.penup)
    if (a == '落笔'):
        fanc.appned(turtle.pendown)
    if (a == '隐藏'):
        fanc.append(turtle.hideturtle)
    if (a == '移动'):
        def f8():
            yiX = int(input('X:'))
            yiY = int(input('Y:'))
            turtle.goto(yiX, yiY)
        fanc.append(f8)
    if (a == '移动X'):
        def f9():
            XXX=int(input('X:'))
            turtle.setx(XXX)
        fanc.append(f9)
    if (a == '移动Y'):
        def f10():
            YYY = int(input('Y:'))
            turtle.sety(YYY)
        fanc.append(f10)
    if (a == '清除'):
        fanc.append(turtle.clear)
    if (a == '归位'):
        fanc.append(turtle.home)
    if (a == '重置'):
        fanc.append(turtle.reset)
    if (a == '帮助'):
        print('支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度[1-10] 移动 移动X 移动Y 清除 归位 重置'+' 运行')

)

点赞1


评论