Ignore keystrokes in Tk

L

Larry

Another Tk question ... I have a textbox that I want to populate from
my script, and I want the user to be able to select and copy from the
textbox, but I don't want them to be able to modify it. There is a
"-state disabled" attribute which prevents them from modifying, but it
also prevents them from selecting text.

I'm thinking I need to do something with "bind" but I can't figure out
what. I tried binding the <Key> event to a subroutine that returns 0,
or returns 1, and neither had any effect.
 
E

Eric Bohlman

Another Tk question ... I have a textbox that I want to populate from
my script, and I want the user to be able to select and copy from the
textbox, but I don't want them to be able to modify it. There is a
"-state disabled" attribute which prevents them from modifying, but it
also prevents them from selecting text.

By a "textbox" do you mean an Entry or a Text? If the latter, there's
already an ROText that will do what you want.
 
L

Larry

Larry said:
It's actually a "Scrolled".

Oh, I get it... I didn't realize that the Scrolled had "Text" as an
option. I changed it to "ROText" and that did the trick. (Except that
it also made the background gray, but I was able to fix that with
"-background white").

Thanks!
 
E

Eric Bohlman

Oh, I get it... I didn't realize that the Scrolled had "Text" as an
option. I changed it to "ROText" and that did the trick. (Except
that it also made the background gray, but I was able to fix that with
"-background white").

It's not an "option"; it's a "subwidget" (Scrolled is actually a composite
widget consisting of a user-specified subwidget and two scrollbar
subwidgets).

And thanks for reminding me about the background issue; I had forgotten
about it and was wondering why the ROText I'm using in a quote-collection-
viewer looked so off.
 

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

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top