tkinter event 冲突

tkinter <Button-1> <ButtonPress-1> <ButtonRelease-1>冲突

def link(textobj, place, color, underline, execcmd, var):
	exec('textobj.tag_add(var, place[0], place[1])')
	exec('textobj.tag_config(var, foreground = color[0], background = color[1], underline = underline)')
	textobj.config(cursor = 'arrow')
	def show_hand_cursor(event):
		textobj.config(cursor = 'hand2')
	
	def show_xterm_cursor(event):
		textobj.config(cursor = 'xterm')
	
	def onclick(event):
		nonlocal execcmd
		exec(execcmd)
	
	def onmousedown(event):
		nonlocal textobj, var, color
		exec('textobj.tag_config(var, foreground = color[3], background = color[1])')
	
	def onmouseup(event):
		nonlocal textobj, var, color
		exec('textobj.tag_config(var, foreground = color[2], background = color[1])')
	
	exec("textobj.tag_bind(var, '<Enter>', show_hand_cursor)")
	exec("textobj.tag_bind(var, '<Leave>', show_xterm_cursor)")
	exec("textobj.tag_bind(var, '<Button-1>', onclick)")
	exec("textobj.tag_bind(var, '<ButtonPress-1>', onmousedown)")
	exec("textobj.tag_bind(var, '<ButtonRelease-1>', onmouseup)")

 

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^