This code:
package require Tk
set sandbox [safe::interpCreate sandbox]
safe::loadTk $sandbox
$sandbox eval $test_code
where $test_code is the calculator from this page:
https://wiki.tcl.tk/1270
gives me this:
invalid command name "wm"
while executing
"wm title . Calculator"
invoked from within
"$sandbox eval $test_code"
It works fine if I dispense with a safe interp and just do this;
set sandbox [interp create sandbox]
$sandbox eval $test_code
but adding a-safe argument and adding back loadTk to that causes a different error:
can't read "state(access_path,remap)": no such element in array
while executing
"dict exists $state(access_path,remap) $path"
(procedure "::safe::interpAddToAccessPath" line 6)
invoked from within
"::safe::interpAddToAccessPath $slave $tk_library"
(procedure "tkInterpInit" line 11)
invoked from within
"tkInterpInit $slave [list "-use" $use "-display" $display]"
(procedure "safe::loadTk" line 59)
invoked from within
"safe::loadTk $sandbox"
its looks like safe:interpCreate and loadTk is getting me closest to what I want, but nothing I have tried actually works.