[Tutor] Read - Only Text?
Tim Johnson
tim@johnsons-web.com
Mon, 5 Mar 2001 07:56:00 -0900
Hi Michael:
On Mon, 05 Mar 2001, Michael P. Reilly wrote:
<snip>
>
> About the "best" way (which I've still found some problems with) is to
> use a Text widget and to unbind the key events in the Text "class".
> This is fairly drastic, because it will apply the change to all Text
> widgets ("class" here is a GUI term, not Python's classes). The reason
> this has to be done is because Tk has a multilevel event binding: first
> the widget's specific binding, then the class's binding. You could
> remove or override the key bindings (<KeyPress>, <KeyRelease>) on the
> widget, but the classes bindings would still be there.
>
> How I've removed them is:
> master.unbind_class("Text", "<Return>")
> master.unbind_class("Text", "<Any-KeyPress>")
> master.unbind_class("Text", "<Any-KeyRelease>")
> textwid = Text(master, ...)
===========================================================
I am unclear from the code above what class "master" is instantiated from.
Is it the main Tk() object?
===========================================================
[In time crunch today, so don't have time to experiment 'til evening :>) ]
> Notice that I don't use the widget itself to unbind the Text class. It
> is a global change, so it can work on just about any widget. After
> this you may bind more events to the widget itself.
>
> But, the issue is that this will make the change to ALL Text widgets in
> your application, not just the one you create.
>
> You might want to look at my Xmore application where I do this (with
> one bug on the ^o key that I never figured out, which does modify the
> text).
I have downloaded Xmore and will look at it more today. Nice stuff, it's
going to be good code to review!!
===============
Thanks Michael!
===============
--
Tim Johnson
-----------
"Of all manifestations of power,
restraint impresses the most."
-Thucydides