我正在尝试绘制一个插孔灯,我无法弄清楚如何应用我定义的这些参数...我有什么功能来绘制我创建的随机形状?
from turtle import*
pumpkin_size=input("Would you like your pumpkin to be tall, fat, or small? ")
turtle_1=Turtle()
turtle_2=Turtle()
def tall_pumpkin():
color("orange")
shape("circle")
shapesize(20,16,5)
fillcolor("orange")
def fat_pumpkin():
color("orange")
shape("circle")
shapesize(15,18,5)
def small_pumpkin():
color("orange")
shape("circle")
shapesize(14,14,5)
interpret_size = {
"fat": "fat_pumpkin",
"tall": "tall_pumpkin",
"small": "small_pumpkin",
}
exitonclick()
答案 0 :(得分:0)
一些修复方法可以解决问题:
Picasso.with(getActivity()) // instead of getActivity() you could pass there any context
.load(avatarUrl)
.into(yourImageViewWithAvatar);
首先你需要声明一个画布对象,然后使用from turtle import *
canvas = Screen()
canvas.setup(400,200)
pumpkin_size = raw_input("Would you like your pumpkin to be tall, fat, or small? ")
turtle = Turtle()
print 'selection {}'.format(pumpkin_size)
def tall_pumpkin():
turtle.color("orange")
turtle.shape("circle")
turtle.shapesize(20,16,5)
turtle.fillcolor("orange")
def fat_pumpkin():
turtle.color("orange")
turtle.shape("circle")
turtle.shapesize(15,18,5)
def small_pumpkin():
turtle.color("orange")
turtle.shape("circle")
turtle.shapesize(14,14,5)
interpret_size = {
"fat": fat_pumpkin,
"tall": tall_pumpkin,
"small": small_pumpkin,
}
interpret_size[pumpkin_size]()
canvas.exitonclick()
而不是"fat": fat_pumpkin
,现在你可以调用"fat": "fat_pumpkin"
来调用输入中键的函数。
还有一件事是使用您的interpret_size[pumpkin_size]()
实例并设置自己的属性,例如turtle
或color
。
shape