Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

making a section of a Tk::Text widget read only

by bobdeath (Scribe)
on Jun 25, 2003 at 14:54 UTC ( [id://268875]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://268875]
Approved by P0w3rK!d
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-19 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found