Using PAR/pp with Tcl::Tk

[email protected] Mon, 12 Aug 2019 22:40:31 +0200
Newsgroups perl.tcltk
Message-ID <trinity-321f3070-b6c3-4109-be35-bb4dfea2c61a-1565642431731@3c-app-gmx-bs20>
=C2=A0
Hello everybody,
=C2=A0
I wanted to share with you, how I could use pp with Tcl::Tk=2E This topic =
was discussed here some years ago (see https://www=2Enntp=2Eperl=2Eorg/grou=
p/perl=2Etcltk/2015/09/msg682=2Ehtml), but the proposed solutions didn't wo=
rk for me=2E

The problem is, that one has to change the shell environment variabe $ENV{=
TCL_Library}=2E But this is not simple, because the child process (the perl=
 program) cannot change the environment variables of the parent process=2E

My solution was the following BEGIN block:

BEGIN {
	if ($ENV{PAR_TEMP} && $ENV{TCL_Library} ne "$ENV{PAR_TEMP}/inc/lib/tcl8=
=2E6") {
		print "Starting a Tcl::Tk PAR-exe file\n";
		print "We need to set shell environment variables first \n";	=09
		$ENV{TCL_Library} =3D "$ENV{PAR_TEMP}/inc/lib/tcl8=2E6";
		# I don't know whether this is really necessary?	=09
		$ENV{TK_Library} =3D "$ENV{PAR_TEMP}/inc/lib/tcl8=2E6";
		system($0);
		exit();=09
	}
}

To pack the perl script I use this command:

pp -l "C:/Tcl/bin/tcl86=2Edll" -l "c:/Tcl/bin/tk86=2Edll" -l "c:/Tcl/bin/z=
lib1=2Edll" -a "C:/Tcl;=2E/" -o tktest=2Eexe =2E/tktest=2Epl

Important is to rename the directory C:/Tcl to "=2E/"=2E Especially you mu=
st have the point before the "/"=2E I don't know why ;-) but it works =2E=
=2E=2E

Perhaps this is helpful for someone=2E=2E=2E

Best wishes,
Max