|
2015-10-08
| ||
| 08:43 | • Closed ticket [61f5037750]: wish doesn't print to stdout on windows plus... artifact: 4731a01196 user: jan.nijtmans | |
| 05:56 | • Ticket [61f5037750]: 3 changes artifact: 1d8ffba935 user: apnadkarni | |
| 04:59 | • New ticket [61f5037750]. artifact: 29f777aad3 user: anonymous | |
wish doesn't print to stdout on windows
Closed / Invalid61f50377506aeb6ebb85a242b3e5ac592bf3aef5Created 11 years agoUpdated 11 years ago
Descriptionplain2015-10-08 04:59:03
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]
apnadkarniplain2015-10-08 05:56:20
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.
jan.nijtmansplain2015-10-08 08:43:31
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.
Log in (anonymous is fine) to add a comment.