第13772题 单选题
Python Tkinter实现鼠标移到按钮变红、移开变蓝,划线处应填入的代码是?

以下代码实现将鼠标移到按钮上时按钮变红,鼠标移开时按钮变蓝,划线处的代码是?

from tkinter import *
root = Tk()
root.title( )
root.geometry('450x350')
btn1 = Button(root,text = '1')
btn1.place(x =200,y = 50,width = 40,height = 40)
def changebg(event):
    # 鼠标移到按钮上按钮变红
    event.widget['bg'] = 'red'
def changebg1(event):
    # 鼠标离开按钮上按钮变蓝
    event.widget['bg'] = 'blue'
____________
btn1.bind('<Leave>',changebg1)
root.mainloop()
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析