海龟画图屏幕失去焦点与得到焦点

海龟画图屏幕失去焦点与得到焦点

当屏得到焦点时显示红色,失去焦点时显示灰色

"""
   海龟画图屏幕失去焦点与得到焦点
"""

from turtle import *

def got_focus(event):
    print(dir(event))
    screen.bgcolor('#333333')

def lost_focus(event):
    print(dir(event))
    screen.bgcolor('dodger blue')

screen = Screen()
screen.setup(480,360)
screen.cv.bind("", got_focus)
screen.cv.bind("", lost_focus)


李兴球

李兴球的博客是Python创意编程原创博客

评论已关闭。