Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么tkinter<;输入>;及<;离开>;事件不起作用?_Python_Python 3.x_Tkinter_Events - Fatal编程技术网

Python 为什么tkinter<;输入>;及<;离开>;事件不起作用?

Python 为什么tkinter<;输入>;及<;离开>;事件不起作用?,python,python-3.x,tkinter,events,Python,Python 3.x,Tkinter,Events,当鼠标悬停在我的小部件上时,我试图让它亮起来。以下是我尝试过的: self.buttons = [] self.buttonTips = ["Select and Add a clip to the project", "Order the clips in your project", "Trim the selected clip", "Cut out audio breaks in

当鼠标悬停在我的小部件上时,我试图让它亮起来。以下是我尝试过的:

self.buttons = []
self.buttonTips = ["Select and Add a clip to the project", "Order the clips in your project", "Trim the selected clip",
                   "Cut out audio breaks in the selected clip", "Preview clip (in new window)", "Render/Export your video"]
self.commands = [self.getClipPath, self.reorderClips, self.trimClip, self.cutOutAudio, self._preview, self.finishVideo]
self.images = [_addImage, _switchImage, _trimImage, _autoTrimImage, _previewImage, _exportImage]

for index, tip in enumerate(self.buttonTips):
    self.buttons.append(Button(self.root, image=self.images[index], command=self.commands[index], bg=_bgcolor, relief=FLAT))
    self.buttons[index].photo = self.images[index]
    self.buttons[index].place(x=index * 30, y=490)
    self.buttons[index].bind("<Enter>", func=partial(changeButtonBG, 1, self.buttons[index]))
    self.buttons[index].bind("<Leave>", func=partial(changeButtonBG, 0, self.buttons[index]))

    addToolTip(self.buttons[index], tip)
self.buttons=[]
self.buttonTips=[“选择并向项目中添加剪辑”,“在项目中排序剪辑”,“修剪所选剪辑”,
“在选定剪辑中剪切音频中断”、“预览剪辑(在新窗口中)”、“渲染/导出视频”]
self.commands=[self.getClipPath,self.reorderciples,self.trimciple,self.cutOutAudio,self.\u preview,self.finishVideo]
self.images=[\u addImage、\u switchImage、\u trimmage、\u autotrimage、\u previewImage、\u exportImage]
对于索引,在枚举中提示(self.buttonTips):
self.buttons.append(按钮(self.root,image=self.images[index],command=self.commands[index],bg=\bgcolor,relief=FLAT))
self.buttons[index].photo=self.images[index]
self.button[index].place(x=index*30,y=490)
self.buttons[index].bind(“,func=partial(changeButtonBG,1,self.buttons[index]))
self.buttons[index].bind(“,func=partial(changeButtonBG,0,self.buttons[index]))
添加工具提示(自我按钮[索引],提示)

当我将事件类型更改为函数时,函数运行良好,但当我使用或它不工作时?有人知道为什么吗?

好的,我已经解决了我的问题。在此行中:

addToolTip(self.buttons[index], tip)
addToolTip()函数还向小部件添加绑定。因此,我编辑了绑定,使其具有:

button.bind(func=function, add="+")

添加
add=“+”
使其工作

我不明白“当我将事件类型更改为函数时,功能运行良好,但当我使用或不工作时”是什么意思。请编辑您的问题并澄清。对不起,我打错了它-显然不能在运动中不使用后座“……但当我使用或它不工作时?”仍然没有。我现在已经回答了我的问题