2017-12-08 2 views
0

뭔가가 트리거 거북이 코드를 작성하려고하고있다, 그래서 나는 turtle.bye()을 사용하려고하지만 오류가 계속 :파이썬은 '거북이'객체는 거북이 창을 닫 어떤 속성 '안녕'

Exception in Tkinter callback 
Traceback (most recent call last): 
    File "C:\Program Files\Python36\lib\tkinter\__init__.py", line 1699, in 
__call__ 
    return self.func(*args) 
    File "C:\Program Files\Python36\lib\turtle.py", line 686, in eventfun 
    fun() 
    File "E:\Home made game\Chapter 1 Log Cabin.py", line 346, in k1 
    player.bye() 
AttributeError: 'Turtle' object has no attribute 'bye' 
+0

방금 ​​** 거북이 **를 설치했으며 빠르게 살펴 봤습니다. turtle.bye()와 turtle.Screen(). bye()는 작동하지 않지만 메인 루프는 시작하지 않았습니다. 거북이 mainloop()을 시작하셨습니까? – Gary02127

+0

샘플 코드를 게시 할 수 있습니까? – Gary02127

답변

0

bye()은 Turtle이 아닌 Screen singleton 인스턴스의 메서드입니다. 또한 거북이 패키지의 최상위 함수에 매핑됩니다. Turtle 인스턴스에서는 작동하지 않습니다. 당신은 그것을 몇 가지 방법을 호출 할 수 있습니다

import turtle 

turtle.Screen().bye() # not a turtle instance, the turtle package 

turtle.bye() # not a turtle instance, the turtle package 

turtle.getscreen().bye() # not a turtle instance, the turtle package 

yertle = turtle.Turtle() 
yertle.getscreen().bye() # turtle instance gets screen singleton to invoke bye() 

당신이 거북이의 세계를 다시 시작해야 의미가 아니에요 방식으로 종료 bye()를 호출하면.