我现在正在使用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 ()
任何帮助表示赞赏!
答案 0 :(得分:2)
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()
我得到印度国旗: