# Tk Text box

**URL:** <https://www.ruby-forum.com/t/tk-text-box/182510>\
**Category:** Ruby\
**Created:** [January 29, 2010, 5:45am UTC](https://www.ruby-forum.com/t/tk-text-box/182510 "2010-01-29T05:45:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philliam\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@Philliam\_A](https://www.ruby-forum.com/u/Philliam_A)\
**Post date:** [January 29, 2010, 5:45am UTC](https://www.ruby-forum.com/t/tk-text-box/182510/1 "2010-01-29T05:45:29Z")

</div>

Is there any way I can create a text box in Tk that the user cannot  
edit, but the program can edit the value of? I have tried doing state  
(‘disabled’) on a TkText but this makes it not editable at all.

Also, is there a way I can bind an event to someone hitting enter in a  
TkEntry?

---

<div class="post-metadata">

**Author:** ![Philliam\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@Philliam\_A](https://www.ruby-forum.com/u/Philliam_A)\
**Post date:** [January 29, 2010, 8:10am UTC](https://www.ruby-forum.com/t/tk-text-box/182510/2 "2010-01-29T08:10:38Z")

</div>

From: Philliam A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subject: Tk Text box  
Date: Fri, 29 Jan 2010 13:45:06 +0900  
Message-ID:  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

> Is there any way I can create a text box in Tk that the user cannot  
> edit, but the program can edit the value of? I have tried doing state  
> (‘disabled’) on a TkText but this makes it not editable at all.

## Remove its classs from the bindtags of the widget. Probably, it is the most simple way. For example,

## t = TkText.new t.bindtags -= [t.class]

---

<div class="post-metadata">

**Author:** ![Philliam\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/278dde/32.png) [@Philliam\_A](https://www.ruby-forum.com/u/Philliam_A)\
**Post date:** [January 29, 2010, 5:02pm UTC](https://www.ruby-forum.com/t/tk-text-box/182510/3 "2010-01-29T17:02:07Z")

</div>

On Jan 28, 11:10 pm, Hidetoshi NAGAI [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## Probably, it is the most simple way. e = TkEntry.new e.bind(‘Return’){ … callback operation … }
> 
> –  
> Hidetoshi NAGAI (removed\_email\_address@domain.invalid)

Thanks, that’s exactly what I needed.
