Skip to content
Tcl Source Code History Of Ticket 61f50377506aeb6e
Login

History Of Ticket 61f50377506aeb6e

Artifacts Associated With Ticket 61f50377506aeb6e

  1. Ticket change [29f777aad3] (rid 143465) by anonymous on 2015-10-08 04:59:03:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Hi,
      I tried to print to stdout using wish on windows.
      
      I tried this: 
            puts hello
      
      But it doesn't print nothing to stdout.
      
      I developed a code to get the clipboard data from a Tcl program executed using tclsh. But this code doesn't work on windows and I think that the reason is that nothing is sent to stdout. This is the code:
      
      namespace eval clipboard {
          namespace export append clear get close
          namespace ensemble create
          
          variable mypipeline
          
          variable clipboard_data
          variable clipboard_length
          
          proc Initialization {path_to_wish} {
      
              variable mypipeline [open |$path_to_wish r+]
      
              fconfigure $mypipeline -buffering line
      
              puts $mypipeline {fconfigure stdout -buffering line}
              puts $mypipeline {wm withdraw .}
          }
       
          proc append {txt} {
              variable mypipeline
              puts $mypipeline "clipboard append [list $txt]"
          }
          
          proc clear {} {
              variable mypipeline
              puts $mypipeline {clipboard clear}
          }
          
          proc get {} {
              variable mypipeline
              variable clipboard_data
              variable clipboard_length
              
              puts $mypipeline {
                  if {[catch {set clipboard_data [clipboard get]}]} {
                      return 0
                  } else {
                      puts [string length $clipboard_data]
                      puts -nonewline $clipboard_data 
                      flush stdout 
                  }
              }
              
              fileevent $mypipeline readable ::clipboard::GetClipboardLength
      
              vwait getting_length
      
              if {$clipboard_length == 0} {
                  set clipboard_data ""
              } else {
                  fileevent $mypipeline readable ::clipboard::GetClipboardData
                  vwait getting_data
              
                  fileevent $mypipeline readable ""
              }
              return $clipboard_data
              
          }
          
          proc GetClipboardData {} {
              variable mypipeline
              variable clipboard_data
              variable clipboard_length
              
              upvar getting_data getting_data
              
              set clipboard_data [read $mypipeline $clipboard_length]
              
              set getting_data 1
          }
          
          proc GetClipboardLength {} {
              variable mypipeline
              variable clipboard_length
              
              upvar getting_length getting_length
              
              set clipboard_length [gets $mypipeline]       
              
              set getting_length 1
          }
          
          proc close {} {
              variable mypipeline
              close $mypipeline   
          }
          
      }
      
      ::clipboard::Initialization /usr/local/bin/wish8.6
      ::clipboard append hola
      puts [clipboard get]
      
    5. foundin initialized to: "8.6"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "1c4b6cdb98c9dfc4d1e74018f3f4efa00ad217e2"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "25. Channel System"
    15. title initialized to: "wish doesn't print to stdout on windows"
    16. type initialized to: "Bug"
  2. Ticket change [1d8ffba935] (rid 143466) by apnadkarni on 2015-10-08 05:56:20:

    1. icomment:
      I suspect this is because by design wish on Windows has its own "console" window which is where all output to stdout is sent. The puts with clipboard data will be printed to this window (which you can see with "console show") and not to your pipe.
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  3. Ticket change [4731a01196] (rid 143467) by jan.nijtmans on 2015-10-08 08:43:31:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2457303.86356069"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      On Windows, GUI applications don't have stdin/stdout/stderr. However, it is possible to run Tk in a console application.
      
      So: just run tclsh86.exe in stead of wish86.exe. If your scripts starts with "package require Tk", any GUI is usable, and there is a console as well. Any applications which expects stdout to work should do this.
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/plain"
    7. resolution changed to: "Invalid"
    8. status changed to: "Closed"