bobdeath has asked for the wisdom of the Perl Monks concerning the following question:

I am wanting to display a nice header inside of a Tk::Text widget. I then want the user to be able to type things below that header. The problem I am having is that I don't want the user to be able to change the header in any way. It seems that I would be able to do this using some cleaver tricks with tags, but I can't figure out what that trick is. Anyone out there run into a similar problem?
  • Comment on making a section of a Tk::Text widget read only

Replies are listed 'Best First'.
Re: making a section of a Tk::Text widget read only
by bobn (Chaplain) on Jun 25, 2003 at 18:04 UTC
    A quick gander of the doc seems to indicate that you could use tagBind to couple a script to any attempts to change the text, where the script would prevent this, possibly as simpy as by doing nothing.

    Update: this looks less promising, though it still might be doable. However, you can combine ROText and Text Widgets.
    #!/usr/bin/perl -w use Tk; my $mw = MainWindow->new(); my $tr = $mw->ROText(-borderwidth => 1, -height=>1); $tr->pack(); $tr->insert('end', "\t\tReadonly:\n"); my $t = $mw->Text(-borderwidth => 1, -height=>1); $t->pack(); MainLoop;
    Or you can put Label and Entry widgets into a Text widget, as shown in Mastering Perl/Tk

    --Bob Niederman, http://bob-n.com