gpt4 book ai didi

python - 填充颜​​色Python图形(印度国旗)

转载 作者:行者123 更新时间:2023-12-01 04:44:25 25 4
gpt4 key购买 nike

我现在正在用 python 在 Graphwin 图形系统中创建印度国旗。我现在的代码缺少一些东西。当我运行下面的代码时,深绿色覆盖了白色。但是当我从底部删除 setFill('darkgreen') 时,白色显示得很好,并且没有覆盖任何其他内容。我缺少什么?

from graphics import *

def main():
win = GraphWin("India Flag", 500, 500)

pt = Point(50,50)
pt.draw(win)

top = Rectangle(Point(260,100), pt)
top.setFill('orange')
top.draw(win)

pt2 = Point(50, 150)
middle = Rectangle(Point(260,100), pt2)
middle.setFill('white')
middle.draw(win)

pt3 = Point(50, 200)
bottom = Rectangle(Point(260,100), pt3)
bottom.setFill('darkgreen')
bottom.draw(win)

main ()

感谢任何帮助!

最佳答案

from graphics import *

def main():
win = GraphWin("India Flag", 500, 500)
pt = Point(50,50)
pt.draw(win)
top = Rectangle(Point(260,100), pt)
top.setFill('orange')
top.draw(win)
pt2 = Point(50, 150)
middle = Rectangle(Point(260,100), pt2)
middle.setFill('white')
middle.draw(win)
pt3 = Point(260, 200)
bottom = Rectangle(Point(50,150), pt3)
bottom.setFill('darkgreen')
bottom.draw(win)

main()

我得到了以下印度国旗:

enter image description here

关于python - 填充颜​​色Python图形(印度国旗),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29811834/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com