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