我已经从https://pypi.org/project/graphics.py/#description安装了graphics.py,并且正在使用Jupyter笔记本编写代码。我也将graphics.py复制到了与编写代码相同的文件夹路径(jupyter笔记本所属的文件夹)中。为什么会出现此属性错误?
我尝试使用dir()方法找出对象GraphicWin对象中的所有属性,但其中没有显示yUp。我的Jupyter笔记本目录为D:\ JSC \ Scripts,在同一目录中,我创建了一个图形文件夹,并从D:\ Python \ Lib \ site-packages复制了graphics.py库
array.size()
from graphics import *
print(dir(GraphWin))
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()
答案 0 :(得分:3)
用 win.setCoords(0,0,200,150)
替换 win.yUp()答案 1 :(得分:1)
setCoords()方法包含yUp()方法。使用起来有点复杂,但是您可以使用。