AI题库 · Python编程六级题库
题目分享 #5720
以下代码实现将鼠标移到按钮上时按钮变红,鼠标移开时按钮变蓝,划线处的代码是?()
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('',changebg1)
root.mainloop()
A
btn1.bind()
B
btn1.bind('<Enter>',changebg)
C
btn1.bind('<Enter>',changebg1)
D
btn1.bind('<Button-1>',changebg1)
AI题库 · 编程考级与信奥赛真题库
查看答案 →
复制链接后可在微信、QQ、小红书等平台粘贴分享;答案与解析在题目页。