Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read only text widget

Status
Not open for further replies.

anirban2k2001

Programmer
Aug 25, 2003
27
IN
Hi all,

I have a text widget which successfully fetches data from a backend sqlite database and displays it in the text widget.
My requirement is that I want to make the text widget readonly so that no one can edit the fetched data. I use '-state disabled' but that hides the data that is displayed in the text widget.

Kindly help.

The relevant portion of the code is undergiven:
text .f2.t1 -bd 1 -highlightbackground black -highlightthickness 1 -font $fnt9 -state disabled
.f2.t1 insert end [string trim $nm]
place .f2.t1 -x 65 -y 25 -width 170 -height 16

Thanxs in advance.
Anirban Sarkar
 
Hi Anirban,
consider using a label instead of the text widget if you don't need text widget funcionality.

Your code example doesn't work because the insert operation requires that widget state is not disabled.

Change it to the following:
Code:
text .f2.t1 -bd 1 -highlightbackground black -highlightthickness 1 -font $fnt9
   .f2.t1 insert end [string trim $nm]
   .f2.t1 configure -state disabled
   place .f2.t1 -x 65 -y 25 -width 170 -height 16
if You want to add $more_text later, enable it before inserting:
Code:
.f2.t1 configure -state normal
.f2.t1 insert end $more_text
.f2.t1 configure -state disabled

HTH
Tobias



Tobias Gabele
Bierwirth & Gabele SoftwareDesign GBR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top