Skip to content

Link R with Tcl 8.6 on Windows

3 messages · Adrian Waddell, Karim Mezhoud

#
Dear all,

I am working on an R package intended for CRAN that requires Tcl version 8.6 because of the TclOO tcl extension and the -angle option for canvas text items.

R for Windows currently still ships with Tcl 8.5. Does anyone have experience with linking R under Windows to a Tcl interpreter of version 8.6?

When I link R 3.2.2 (installed from the binary on Windows 8) to a custom Tcl installation of version 8.6 (e.g. from ActiveState for both 32bit or 64bit) using the MY_TCLTK environment variable, then loading the tcltk package will result with a tk85.dll not found error. This problem can be ?fixed? by copying and renaming the tk86.dll and the tcl86.dll files in the bin folder of the activetcl installation to tk85.dll and tcl85.dll.

However, this setup does not work well for me; sometimes, when creating a number of involved toplevel windows at once, some of them are not created properly and are left completely unresponsive, see the attached image. I have not managed to create a small contained example so far. But I can share my code, if necessary.

Is there a reason that under Windows R looks for the tk85.dll in particular, effectively forcing the Tcl version to 8.5? Also, does anyone know a remedy to this gui error?

Thanks,

Adrian Waddell
R version 3.2.2 (2015-08-14)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 8 x64 (build 9200)

locale:
    [1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

attached base packages:
    [1] tools     tcltk     stats     graphics  grDevices utils     datasets
[8] methods   base

other attached packages:
    [1] loon_0.8.4.4
#
Hi,
I Think you can install devel version by:

 devtools::install_github("tcltk/tcl")

from this link https://github.com/tcltk/tcl

Karim
On Mon, Sep 28, 2015 at 6:36 PM, Adrian Waddell <adrian at waddell.ch> wrote:

            

  
  
#
OK, I have the answers to my questions:

The GUI error in Windows happens for the sequence: create a toplevel in 
Tcl, set an icon, pack something. A small self contained example is:

library(tcltk)

.Tcl("

     set icon [image create photo -width 30 -height 20]

     $icon put blue -to 0 0 30 20; $icon put yellow -to 0 6 30 11



      proc foo {} {

         set i 0

         while {[winfo exists .w$i]} {

             incr i

         }

         toplevel .w$i

         wm iconphoto .w$i $::icon

         canvas .w$i.c -bg steelblue

         pack .w$i.c -fill both -expand TRUE

      }

   ")



.Tcl('foo')

Not setting the icon or replacing the "toplevel .w$i" command with the 
tktoplevel() R callback will fix the problem.

As for linking Tcl version 8.6 with R under Windows: I have compiled R 
against ActiveTcl version 8.6 which works without the necessity of 
copying and renaming the dlls. So far, ActiveTcl 8.6 works well.

Adrian
On 2015-09-28 07:36 PM, Adrian Waddell wrote: