测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A32425. 以下代码实现将鼠标移到按钮上时按钮变红,鼠标移开时按钮变蓝,划线处的代码是? ( )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):#鼠标移到…

单选题 困难

题目描述

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

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()


选项(单选)

上一题 下一题