Posted to tcl by aspect at Thu Feb 04 13:20:39 GMT 2016view raw

  1. package require Tk
  2. wm withdraw .
  3. set c ""
  4. catch {
  5. set c [clipboard get]
  6. }
  7. puts "Old clipboard: {$c}"
  8. puts -nonewline "Enter text: "
  9. flush stdout
  10. gets stdin text
  11. clipboard clear
  12. clipboard append $text
  13. puts "Clipboard is now: {[clipboard get]}"
  14. puts "sleeping ..."
  15. if 0 {
  16. # this version services the event loop while sleeping, so the clipboard can be retrieved
  17. after 5000 {incr ::done}
  18. vwait ::done
  19. }
  20. if 1 {
  21. # this version blocks the event loop -- 2nd process gets nothing
  22. # (as opposed to blocking in Tkinter)
  23. after 5000
  24. }
  25. puts "finished!"
  26. exit
  27.