[R] pure TCL run a command within the R via the tcltk package?

Cleber N.Borges klebyn at yahoo.com.br
Mon Oct 10 18:26:57 CEST 2016


thanks Jonh Fox!  :-)
my solution (partial and temporary) was as follows.
cleber
( for the  r-help history file )
############################################
library( tcltk )
# from  ?.Tcl
f <- function()cat("HI!\n")
.Tcl.callback(f)

sink("simpletest.tcl")
cat('toplevel .t\n')
cat('button .t.b -text "but" -command { ',  .Tcl.callback(f), ' }\n' )
cat('checkbutton .t.c -text "ck1" -variable "chkvar"\n' )
cat('pack .t.b\n')
cat('pack .t.c\n')
sink()

#tcl('set', 'argc', '0') # for use with code generated by vTcl
#tcl('set', 'argv', '0') # for use with code generated by vTcl
tcl('source', "simpletest.tcl" )
tclvalue('chkvar')

unlink('simpletest.tcl')


Em 10/10/2016 11:02, Fox, John escreveu:
> Dear Cleber,
>
> See ?.Tcl
>
> I hope this helps,
>   John
>
> -----------------------------
> John Fox, Professor
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> Web: socserv.mcmaster.ca/jfox
>
>
>
>
>> -----Original Message-----
>> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Cleber
>> N.Borges via R-help
>> Sent: October 9, 2016 9:00 PM
>> To: r-help at r-project.org
>> Subject: [R] pure TCL run a command within the R via the tcltk package?
>>
>> Dear,
>> is there any way of a button on pure TCL run a command within the R via the
>> tcltk package?
>> thank you in advance for informations
>> cleber
>> what I have in mind is something like:  (below)
>> ##################################################################
>> ########################
>> sink("simpletest.tcl")
>> cat('
>> toplevel .t
>> button .t.b -text "but" -command {"some tcltk command for push data into R"}
>> checkbutton .t.c -text "ck1" -variable "chkvar"
>> pack .t.b
>> pack .t.c '
>> )
>> sink()
>>
>> library( tcltk )
>> #tcl('set', 'argc', '0')
>> #tcl('set', 'argv', '0')
>> tcl('source', "simpletest.tcl" )
>>
>>   > tclvalue('chkvar')
>> [1] "1"
>>   > tclvalue('chkvar') # after click in screen [1] "0"
>>   >
>>
>> ### after click in button  get error:
>>
>> invalid command name "some tcltk command for push data into R"
>> invalid command name "some tcltk command for push data into R"
>>       while executing
>> ""some tcltk command for push data into R""
>>       invoked from within
>> ".t.b invoke"
>>       ("uplevel" body line 1)
>>       invoked from within
>> "uplevel #0 [list $w invoke]"
>>       (procedure "tk::ButtonUp" line 24)
>>       invoked from within
>> "tk::ButtonUp .t.b"
>>       (command bound to event)
>>
>> ##################################################################
>> ########################
>>   > sessionInfo()
>> R version 3.3.1 (2016-06-21)
>> Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64
>> (build 7600)
>>
>> locale:
>> [1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252
>> [3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C [5]
>> LC_TIME=Portuguese_Brazil.1252
>>
>> attached base packages:
>> [1] tcltk     stats     graphics  grDevices utils     datasets methods
>> base
>>   >
>>

---
Este email foi escaneado pelo Avast antivírus.
https://www.avast.com/antivirus



More information about the R-help mailing list