Unbind initial bind on basic widget (text)

A

Askari

Hi,
Do I can unbind the initial bind on basic widget? (ex.: the basic widget
Text have the bind "<Control-a>" for the return to the first caracter of
the line; but me I don't want this!)
I try 'myText.unbind("<Control-a>")' but the bind is not remove.
:-(


Askari

N.B. I wan't disabled ALL initial bind (not just the "<Control-a>")
 
P

Peter Otten

Askari said:
Do I can unbind the initial bind on basic widget? (ex.: the basic
widget
Text have the bind "<Control-a>" for the return to the first caracter of
the line; but me I don't want this!)
I try 'myText.unbind("<Control-a>")' but the bind is not remove.
:-(

I see two options.

1. Prevent the event from being propagated to the class.

def breaker(*args):
return "break"

mytext.bind("<Control-a>", breaker)

2. Unbind the event on the class level.

mytext.unbind_class("Text" said:
N.B. I wan't disabled ALL initial bind (not just the "<Control-a>")

Maybe you should just disable the widget?

mytext["state"] = "disabled"

Peter
 
J

Jeff Epler

You should probably read the Tk manpage on the bind and bindtags
commands.

If you want to get rid of all the normal bindings for a Text widget, you
can just do something like
tags = myText.bindtags()
tags.remove("Text")
myText.bindtags(tags)

If you want to stop only certain bindings, use the "break" technique
mentioned in another response to your post.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAy64FJd01MZaTXX0RAsvrAJ4yI+7QYEN0i2iS9s9SvBGNIuayRACeJb5s
PjfGZWjPiWqoLHuAxtAcXj4=
=Xaum
-----END PGP SIGNATURE-----
 
A

Askari

Askari said:
Do I can unbind the initial bind on basic widget? (ex.: the basic
widget
Text have the bind "<Control-a>" for the return to the first caracter
of the line; but me I don't want this!)
I try 'myText.unbind("<Control-a>")' but the bind is not
remove.
:-(

I see two options.

1. Prevent the event from being propagated to the class.

def breaker(*args):
return "break"

mytext.bind("<Control-a>", breaker)

2. Unbind the event on the class level.

mytext.unbind_class("Text" said:
N.B. I wan't disabled ALL initial bind (not just the "<Control-a>")

Maybe you should just disable the widget?

mytext["state"] = "disabled"

Peter

Thanks!! :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top