Posted to tcl by mjanssen at Fri Dec 08 20:36:13 GMT 2006view raw
- package require Tk
- text .t
- pack .t
- .t insert 1.0 test
- proc save_state { widget } {
- variable state
- set state($widget) [$widget get 1.0 end]
- }
- proc restore_state {widget} {
- variable state
- $widget delete 1.0 end
- $widget insert 1.0 $state($widget)
- bind $widget <KeyPress> {}
- }
- proc display_result {} {
- save_state .t
- .t delete 1.0 end
- .t insert 1.0 {this is the result}
- bind .t <KeyPress> {restore_state .t ; break}
- }
- display_result
- # from here everything is handled by events