in reply to Re: call a sub from Tcl code in Tcl::pTk
in thread call a sub from Tcl code in Tcl::pTk

Your question reveals an inside-out approach.

The ->Eval method is meant for exceptional stuff which can't be done with normal Perl methods.

The normal approach is to use standard pTk->methods to build menus and windows.

If your special wish is even possible I doubt that you'll get a quick answer here.

edit

Anyway ... if you just want to generate Tcl code from a Perl method inside your template you can do something like

->Eval(<<"__TCL__"); ... some Tcl Code @{[ my_perl_sub() ]} ... more Tcl Code __TCL__

the result from my_perl_sub() is inserted as string then, which will be interpreted as Tcl code.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^3: call a sub from Tcl code in Tcl::pTk
by Anonymous Monk on Apr 30, 2021 at 19:50 UTC

    Thank you LanX for your answer. I agree that ->Eval is to be used for exceptional cases where pTk->methods are not available. The case presented above is (should be) such a cases, since there are no Perl or pTk methods to manipulate the macOS menu. Such methods are instead available in the Tcl/Tk.