Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Errors using tk from a safe interp

54 views
Skip to first unread message

graemep

unread,
Sep 23, 2017, 12:23:47 PM9/23/17
to
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.

Arjen Markus

unread,
Oct 3, 2017, 9:56:07 AM10/3/17
to
Probably the easiest way is to import the various Tk commands into the safe interpreter via aliases. There is some discussion about this at http://wiki.tcl.tk/4204

Regards,

Arjen
0 new messages