Rakesh Lyf Iz Jrny
Rakesh Lyf Iz Jrny

Reputation: 21

tcl entry with some default text

I want an entry widget with some default text shown in the box. -state disable. When I click on edit button, it will be enable and I can able to change the text. I can manage the Edit button portion, just need help about the entry widget.

I have tried with this code :

entry .e1 -text "abcd" -state disable
pack .e1 -in .WorkArea -side left

Upvotes: 0

Views: 1712

Answers (1)

Peter Lewerin
Peter Lewerin

Reputation: 13252

frame .workArea
pack .workArea

Note that the -text option is an abbreviation of -textvariable, i.e. the name of a global variable that contains the text entered into the entry widget. Setting that variable to a value gives the entry some text.

entry .e1 -textvariable abcd -state disabled
set abcd wxyz
pack .e1 -in .workArea -side left

You now need a button that configures the entry widget to be normal (enabled) when it is pushed:

button .b1 -text Enable -command {.e1 configure -state normal}
pack .b1 -in .workArea -side left

Documentation: button (widget), entry, frame (widget), pack, set

Upvotes: 1

Related Questions