Posted to tcl by emiliano at Wed Dec 18 14:03:00 GMT 2019view raw

  1. namespace eval ::roText {
  2. proc roText {w args} {
  3. text $w {*}$args
  4. rename $w ::roText::$w
  5. proc ::$w {cmd args} [format {
  6. set w %s
  7. if {$cmd ni "insert delete"} {
  8. ::roText::$w $cmd {*}$args
  9. }
  10. } $w]
  11. bind $w <Destroy> [list rename $w {}]
  12. }
  13. }
  14.  
  15. # testing
  16. package require Tk
  17. roText::roText .txt
  18. pack .txt
  19. .txt insert end "This is a test"; #nothing happens
  20. after 5000 {roText::.txt insert end "Insert using the widget command"}