Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

TkDND with PAR::Packer

by Anonymous Monk
on Feb 23, 2017 at 04:29 UTC ( [id://1182585]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I'm having a problem getting a script with a Tkx and TkDND front end to work using pp. I want to distribute the script to some of my colleagues at work and can't. pp builds and I can distribute a program and it runs but doesn't display the main window. I did find one work around but it's not practical. Putting the TkDND folder into System\Library\Tcl\8.5\TkDND makes the main window visible on other computers running the package. But alas our work computers don't allow folders to be copied to System with out admin login in. Not about to do this for the 20 computers I want to install on. I found the following on line:

use File::Spec::Functions; BEGIN { if (exists $ENV{PAR_PROGNAME}) { use Config (); $ENV{PERL_TCL_DL_PATH} = catfile( $ENV{PAR_TEMP}, 'tkkit.' . $Config::Config{dlext}, ); } }

and added it to my script but it looks to be a windows fix that did nothing for me. I also tried to force the TkDND piece into PAR PACKER using:

 pp -o sf -z 9 -f PodStrip -M utf8 -M Tk::Text -l /System/Library/Tcl/8.4/tkdnd2.8/libtkdnd2.8.dylib -l  /System/Library/Tcl/8.4/tkdnd2.8/pkgIndex.tcl -l  /System/Library/Tcl/8.4/tkdnd2.8/tkdnd_compat.tcl -l /System/Library/Tcl/8.4/tkdnd2.8/tkdnd_generic.tcl -l  /System/Library/Tcl/8.4/tkdnd2.8/tkdnd_macosx.tcl -l  /System/Library/Tcl/8.4/tkdnd2.8/tkdnd_unix.tcl -l  /System/Library/Tcl/8.4/tkdnd2.8/tkdnd_windows.tcl -l  /System/Library/Tcl/8.4/tkdnd2.8/tkdnd.tcl sfh2a_tkx.pl

The package gets bigger but still doesn't run. I've wasted two days and am looking for the wisdom of the monks for help. Thanks in advance for helping me to solve this and get some sleep.

Replies are listed 'Best First'.
Re: TkDND with PAR::Packer
by kcott (Archbishop) on Feb 23, 2017 at 09:42 UTC

    Your '/System/Library/...' paths indicate that you're using Mac OS X. With this sort of question it's useful to specify the OS, its version, and the Perl version you're using (along with the versions of any relevant modules). I'm using Mac OS X 10.12.3 (Sierra) and Perl 5.24.0. The version of Tkx I'm using is 1.09: the latest version at the time of writing. The version of pp from 'pp -V': PAR Packager, version 1.036 (PAR version 1.014) (also the latest version).

    "But alas our work computers don't allow folders to be copied to System with out admin login in."

    Not "alas" at all, in my opinion; that's actually very sensible. Don't mess the system Perl (or other system files). If you install a module that currently doesn't exist, the installation may upgrade a module that does exist due to a version dependency, which could break something used by Mac OS X. If you upgrade Mac OS X, it will likely remove the system Perl, along with all related files (modules, utilities, etc.), which will, no doubt, break (some of) your existing Perl programs. I recommend you use Perlbrew: I've been using this on many Mac OS X versions (10.6.x to 10.12.3) over the last seven years - it works well.

    You have inconsistencies in your post that may have some bearing on your problems:

    • In your description you have "System\Library\Tcl\8.5\TkDND"; in your pp command you're using "/System/Library/Tcl/8.4/..." exclusively. Note: 8.5 vs. 8.4; and, incorrect backward slashes (\) in the description.
    • In your pp command you have '-M Tk::Text'. That's a Tk widget, not a Tkx widget.
    "... it runs but doesn't display the main window."

    I don't understand this. What exactly do you mean by "the main window"? Does the GUI not display but some other processing is occurring? Are you getting log entries, screen messages, or something else to indicate that it's running?

    I put together a short script for testing 'pp'. It's basically the "Hello world" code from the Tkx Synopsis, plus a text widget (code from http://www.tkdocs.com/tutorial/morewidgets.html#text). Here's '~/tmp/pm_1182585_tkx_hello.pl' (which runs, without any issues, from the command line):

    #!/usr/bin/env perl use strict; use warnings; use Tkx; my $mw = Tkx::widget->new("."); $mw->new_button( -text => "Hello, world", -command => sub { $mw->g_destroy; }, )->g_pack; my $text_widget = $mw->new_tk__text(-width => 40, -height => 10); $text_widget->g_pack; $text_widget->insert('1.0', 'Test text to test a text widget.'); Tkx::MainLoop();

    I tried 'pp' with just the '-o' option.

    ken@ganymede: ~/tmp $ pp -o pm_1182585_tkx_hello pm_1182585_tkx_hello.pl ken@ganymede: ~/tmp $ ls -al pm_* -rwxr-xr-x 1 ken staff 3261537 Feb 23 19:44 pm_1182585_tkx_hello -rwxr-xr-x 1 ken staff 360 Feb 23 17:27 pm_1182585_tkx_hello.pl ken@ganymede: ~/tmp $ pm_1182585_tkx_hello ken@ganymede: ~/tmp $

    The generated program, 'pm_1182585_tkx_hello', like the original script, 'pm_1182585_tkx_hello.pl', runs without any problems: it appears correctly; the text is displayed; the button works.

    So, the base test shows Mac OS X, 'pp' and 'Tkx' all work together without any special options.

    I'd go back and look at the inconsistencies I mentioned; maybe fixing those might help. I strongly advise you to stop using the system Perl. Upgrade 'pp' and 'Tkx' if you don't have the latest versions.

    You should also try some minimal tests: can you successfully use 'pp' for a basic "Hello world" GUI? Repeat my test with the text widget: does that work? Slowly add elements to the GUI until you find something that fails: it may have nothing to do with 'TkDND'.

    Another thing to check is $PATH. The 'which' command should show both 'perl' and 'pp' in the same 'bin' directory.

    If all of that fails, describe exactly what you've tried, then put together a minimal script, such as I did, using 'TkDND', and describe how that fails (include verbatim warning and error messages).

    — Ken

Re: TkDND with PAR::Packer
by huck (Prior) on Feb 23, 2017 at 06:29 UTC

    is this on windows?

    in Tkx example was:Re^3: Tcl & Tcl::Tk used for 1 main window i posted a working TKDND program i use from time to time. To get it to work i needed to place tkdnd2.6 into a known location (d:\active\tkx_extra\tkdnd2.6) and then use tk-magic

    Tkx::lappend('::auto_path', 'd:\active\tkx_extra\tkdnd2.6'); Tkx::package_require('tkdnd');
    to get tk to search for it there. i suppose that somehow tk knows in your systems to search under System\Library\Tcl\8.5\ for tk packages, but when you did your -l magic with pp that is not where those items ended up.

    tkkit is the name of a reduced tcl/tk environment that activestate perl makes available. based on your System\Library\Tcl\8.5\ path i dont think you are using it, but you might find some clues to extending it in http://grokbase.com/t/perl/tcltk/102hfq8ynx/drag-n-drop-in-perl-tkx/oldest

    i suspect your -l magic with pp is making those needed files available SOMEWHERE. Based on your begin-magic structure above i suspect it is under $ENV{PAR_TEMP} somewhere. you might try playing with variants of

    Tkx::lappend('::auto_path', $ENV{PAR_TEMP}); Tkx::package_require('tkdnd');
    to get it to work. While your pp'ed program is running you might try printing out $ENV{PAR_TEMP} and refining the above path further by searching under it.

    another option might just be to distribute the tkdnd2.8 package and install it to some location you know you can write to, such as where the pp'ed executable is. in that case you could do

    my $where_tkdnd_is=cwd; # or some other way to determine where we are +running from Tkx::lappend('::auto_path', $where_tkdnd_is); Tkx::package_require('tkdnd');
    Im out on a limb again, i dont think its windows 'cus there is no dll, but there is a dylib, but i thought id give it a try at least

Re: TkDND with PAR::Packer
by huck (Prior) on Feb 23, 2017 at 19:48 UTC

    So i was bored and wanted to know more, and searched around.

    The comments from Anonymous Monk and kcott seen very on target, specifically using -a rather than -l

    I do still think you will need to include some sort of Tkx::lappend and Tkx::package_require statements but where should the lappend point to?

    my first clue came in http://www.perl.com/pub/2007/07/ "A further consideration here is PAR , the tool for creating standalone executables from Perl programs. PAR lets you include data files as well as Perl code, so you can bundle a default settings file using a command such as:

    pp hello -o hello.exe -a hello.conf
    which will be available to your script as $ENV{PAR_TEMP}/inc/hello.conf."

    But i kept searching, i may want to use pp sometime myself, and got to http://cpansearch.perl.org/src/RSCHUPP/PAR-Packer-1.036/contrib/docs/where_is_it.txt. Pay particular attention to the sections begining "So much for program components. What if we want to put some data files intothe PAR package?" and then the section begining "So how can I access the files I added with -a or -A ?" and how the clean option modifies what is "unzipped". This will detail what you want to append to $ENV{PAR_TEMP} in the Tkx::lappend call depending on the stuff after the semi-colon in the -a option. I still suspect you will then need the Tkx::package_require('tkdnd'); call.

    Good luck

Re: Tkx TkDND with PAR::Packer
by Anonymous Monk on Feb 23, 2017 at 09:23 UTC

    Hi,

    You're debugging so you should turn on verbosity and debugging so you can see what is going on (what files end up where)

    -M Tk::Text has nothing to do with Tkx module or Tcl module, or "tkdnd" so its not going to help you here

    the -l option is for .dll/.so files not for pkgIndex.tcl....

    You should investigate the -a option you might have better luck with something like -a "C:\Tcl"

    It also maybe be interesting to see what happens with ppsimple.pl

    And if you've got the time and are up for pure experimentation knowing ahead of time it won't be any easier than par/pp just different, maybe http://www.cavapackager.com/appdocs/overview-supportedos.htm

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1182585]
Approved by stevieb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2025-11-10 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (66 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.