Pmw.scrolledText and the <Key> event

Eric Brunel eric.brunel at
Wed Jan 23 10:48:16 CET 2002

Hi Bob,

Bob Greschke wrote:
> I'm trying to make a Pmw.scrolledText widget non-editable, or
> uneditable, or whatever, by the user.  I made my regular Text widgets
> uneditable by binding them to the <Key> event and calling a handler
> that just returned 'break'.

If you want to do that, I suppose you'll have to attach the bind not to the 
whole ScrolledText, but for its 'text' component, like in:
myScrolledText.component('text').bind('<Key>', lambda event: 'break')

> What
> should I be looking for instead, or is there a better way to make then
> uneditable?

Definetely, yes. Just change the state of the same component to DISABLED, 
as in:
(this works if you did a "from Tkinter import *"; if you did "import 
Tkinter", replace DISABLED by Tkinter.DISABLED).

And please note that the DISABLED state is set for you too. That means that 
if you have to change the text in the widget, you'll have to set back its 
state to NORMAL first, change the text and then set the state to DISABLED 

 - eric -

More information about the Python-list mailing list