[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Tk read-only text box

nornagon

5/23/2005 9:56:00 PM

Another Tk question.

Perl/Tk has a widget called Tk::ROText, which acts just like a text
box, with the exception that the user cannot enter text into it.

I need something with the same functionality; I would like the user to
be able to select the text and scroll through it, but not edit it.
Also, I need to be able to change its contents dynamically.

Thanks,
--
- nornagon


6 Answers

Hidetoshi NAGAI

5/24/2005 1:24:00 AM

0

nornagon

5/24/2005 6:40:00 AM

0

On 5/24/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: nornagon <nornagon@gmail.com>
> Subject: Tk read-only text box
> Date: Tue, 24 May 2005 06:56:06 +0900
> Message-ID: <14d6153305052314567ab0b4d9@mail.gmail.com>
> > I need something with the same functionality; I would like the user to
> > be able to select the text and scroll through it, but not edit it.
> > Also, I need to be able to change its contents dynamically.
>
> Hmmm.... Probably there are some ways.
> One of the ways is "block Key events".
> To do that, please use Tk.callback_break.
> For example,
> ---------------------------------------------------
> require 'tk'
> t = TkText.new.pack
> t.bindtags_unshift(b = TkBindTag.new)
> b.bind('Key', proc{ Tk.callback_break })
>
> t.insert(:end, "This is a test message.\n");
>
> Tk.after(10000){t.insert(:end, "This is another test message.\n")}
>
> Tk.mainloop
> ---------------------------------------------------

Interesting. Could you tell me how that works, exactly? Like, what's
bindtags_unshift do? What's a BindTag, even?

Thanks a lot for your patience. ^_^

--
- nornagon


Hidetoshi NAGAI

5/24/2005 8:57:00 AM

0

nornagon

5/25/2005 12:37:00 PM

0

On 5/24/05, Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp> wrote:
> From: nornagon <nornagon@gmail.com>
> Subject: Tk read-only text box
> Date: Tue, 24 May 2005 06:56:06 +0900
> Message-ID: <14d6153305052314567ab0b4d9@mail.gmail.com>
> > I need something with the same functionality; I would like the user to
> > be able to select the text and scroll through it, but not edit it.
> > Also, I need to be able to change its contents dynamically.
>
> Hmmm.... Probably there are some ways.
> One of the ways is "block Key events".
> To do that, please use Tk.callback_break.
> For example,
> ---------------------------------------------------
> require 'tk'
> t = TkText.new.pack
> t.bindtags_unshift(b = TkBindTag.new)
> b.bind('Key', proc{ Tk.callback_break })
>
> t.insert(:end, "This is a test message.\n");
>
> Tk.after(10000){t.insert(:end, "This is another test message.\n")}
>
> Tk.mainloop
> ---------------------------------------------------

Hmm. I've been using this for a while and it works quite nicely.
However, I've noticed that it prevents you from copying from the text
box using Ctrl+C. Is there a way to fix this?

--
- nornagon


Hidetoshi NAGAI

5/25/2005 2:22:00 PM

0

Hidetoshi NAGAI

5/25/2005 9:40:00 PM

0