Tkinter: How to "break" class-event-bindings from within tag-bindings?

Michael Schwarz Minews at
Mon Sep 9 09:01:16 EDT 2002

A "break" as the return value of a tag-event-binding for the 
Text-widget seems not to prevent the standard event-handling of the 
widget to occur.

This seems to be an error!

How can it be done another (elegant) way?

See the following example:


# How can tag-events "break" class-bindings?
from Tkinter import *

def Jump(e):
    # Sprung:
    targetFrom, targetTo = "3.5", "3.9"
    F.Text.tag_remove("sel", "0.0", "end")
    F.Text.tag_add("sel", targetFrom, targetTo)
    F.Text.mark_set("insert", targetFrom)
    return "break" # Doesn't do it !!!

F = Tk()
F.Text = Text(F) # , width=120, height=35, bg="white")
F.Text.pack() # (side="right", fill="both", expand=1)
F.Text.insert(INSERT, """\

F.Text.tag_bind("link", "<1>", Jump)
F.Text.tag_config("link", underline = "on")
F.Text.tag_add("link", "1.0", "1.4")

# Comment the following line and the jump won't do it anymore
# due to the standard class-bindings of the text-widget
F.Text.bind("<1>",lambda e: "break")


More information about the Python-list mailing list