Python“graphics.py”库正在工作,但没有方法。yUp()

2024-06-25 23:04:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经导入了图形库,一切正常。除了假定的.yUp()方法之外,该方法假定可以正确定位图形网格

该方法的文档发布后是否已删除

这是我正在使用的示例(来自http://anh.cs.luc.edu/handsonPythonTutorial/graphics.html

from graphics import *

def main():
    win = GraphWin('Face', 200, 150) # give title and dimensions
    win.yUp() # make right side up coordinates!

    head = Circle(Point(40,100), 25) # set center and radius
    head.setFill("yellow")
    head.draw(win)

    eye1 = Circle(Point(30, 105), 5)
    eye1.setFill('blue')
    eye1.draw(win)

    eye2 = Line(Point(45, 105), Point(55, 105)) # set endpoints
    eye2.setWidth(3)
    eye2.draw(win)

    mouth = Oval(Point(30, 90), Point(50, 85)) # set corners of bounding box
    mouth.setFill("red")
    mouth.draw(win)

    label = Text(Point(100, 120), 'A face')
    label.draw(win)

    message = Text(Point(win.getWidth()/2, 20), 'Click anywhere to quit.')
    message.draw(win)
    win.getMouse()
    win.close()
main()

有人知道为什么win.yUp()似乎不存在了吗


Tags: and方法mainwinheadpointdrawset
1条回答
网友
1楼 · 发布于 2024-06-25 23:04:29

Andrew N.Harrington博士(anh)使用从Zelle版本4.2 5/26/2011中分离出来的John Zelle图形库的变体Zelle当前版本为5 8/26/2016或更高版本

哈林顿的变体增加了:promptMousepromptClose和“是的”。你可以找到它here

您应该能够将yUp()函数从Harrington的源代码复制到您自己的文件中,因为它只是对Zelle的setCoords()函数的一个调用,使用特定的常量来调整窗口

相关问题 更多 >