Posted to tcl by aspect at Thu Feb 04 13:20:39 GMT 2016view raw
- package require Tk
- wm withdraw .
- set c ""
- catch {
- set c [clipboard get]
- }
- puts "Old clipboard: {$c}"
- puts -nonewline "Enter text: "
- flush stdout
- gets stdin text
- clipboard clear
- clipboard append $text
- puts "Clipboard is now: {[clipboard get]}"
- puts "sleeping ..."
- if 0 {
- # this version services the event loop while sleeping, so the clipboard can be retrieved
- after 5000 {incr ::done}
- vwait ::done
- }
- if 1 {
- # this version blocks the event loop -- 2nd process gets nothing
- # (as opposed to blocking in Tkinter)
- after 5000
- }
- puts "finished!"
- exit