Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

PAR and Tk

by nornagon (Acolyte)
on May 16, 2004 at 09:17 UTC ( #353754=perlquestion: print w/ replies, xml ) Need Help??
nornagon has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to distibute a perl application for people without perl. It uses Tk.

I compile it all with pp (no args but the filename). No errors.

When I start up the result .exe file, all I get instead of english characters is boxes and lines.

Help?

Comment on PAR and Tk
Re: PAR and Tk
by PodMaster (Abbot) on May 16, 2004 at 10:27 UTC
    What versions of perl, PAR, Tk?
    Example to try?
    Screenshot?
    I encountered problem with character encodings and Tk804.025, but that's marked as resolved (although that version of PAR hasn't hit CPAN yet, its at http://p4.elixus.org/snap/PAR.tar.gz).

    update: my guess would be it's the same problem, so you should try the newest PAR.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Ah. I was using the ppm version (version 0.75) *downloads*

      Perl version: ActiveState 5.8
      Tk version: 800.025

      Ok, it nmakes fine, then when I nmake test it gives me a bunch of error messages. Mostly 'Can't locate hidden_print.pm or hidden_print_caller.pm'

      But in the end it doesn't complain too much.

      Now to test...

      Aaand... same result. Character encoding problems.

      Code in <readmore>

      All I did was pp dict.pl, then run a.exe and I get the char encoding.

        Hrm. I could see character encoding being an issue if you were looking up dictionary entries in some language other than English, but since you're not doing that, you may need to add some debugging output, so you can compare the "original" output (via "perl your-tk-script.pl") against the "compiled" output. Changing "get_words" to something like this might be instructive:
        sub get_words { my $dict = Net::Dict->new('dict.org'); my $term = $wordbox->get; my $h = $dict->define($term); my $result; my $n = 0; #(update: left line this out earlier, but see below) foreach my $i (@{$h}) { my ($db, $def) = @{$i}; print join "", "$db: $term:\n", map { sprintf("%.2x $_\n",ord( +)) } split( //, $def ); $list->insert('end', "$db: $term"); $defs[$n] = $def; $n++; } }
        (also comment out the "print" statement in "get_def" -- you don't need that one anyway)

        When you run each version of the script (interpreted and compiled), get the same term for each run (e.g. "autotelic" -- my favorite word -- which has a mercifully short output), redirect stdout to a distinct file, then diff the two files. This will tell you at least two things: (1) whether you're getting the same number of characters from each version, and (2) whether there is any systematic bit-wise relation between the characters of the two versions (e.g. for some reason, the compiled version might just be setting the high bit of each character, though I can't imagine how this would come about).

        Apart from that, your code has a problem when I try to put in a second term for definition: in get_word, you reset the array index "$n" for the listbox contents to zero, but you don't remove the prior contents of the listbox.

        I would suggest that you declare a global index counter for @defs (e.g. put  my $ndefs = 0; at the top, and use $ndefs instead of $n in get_words), and never set it back to zero. That way, a user can have multiple terms in the listbox at the same time. (Then you might need a button to delete selected items from the listbox, and/or clear the listbox contents.)

        Thanks for posting your code -- it was my first real introduction to Net::dict, and I could have a lot of fun with that...

        (updated the title to reflect the name of the thread)

Re: PAR and Tk
by Anonymous Monk on May 16, 2004 at 20:50 UTC
    is there a perl equivalent to python's py2exe?
      PAR is goodness. Not sure why you want something else.

      For the record (and on the subject of the original post), I have successfully made Perl/Tk apps with PAR on Win32 (activestate) and the versions of Tk that came with ActiveState (sorry, I don't have version numbers). Use the --gui option to PAR, and be sure to get PAR out of CPAN (it won't require a compiler, it's pure perl...). If you don't get PAR out of CPAN, the --gui option to suppress the DOS box won't be there.

Re: PAR and Tk
by flyingmoose (Priest) on May 17, 2004 at 13:17 UTC
    I compile it all with pp (no args but the filename). No errors.
    Whoa, just thought of something...

    Shouldn't that be: pp -MTk yourcode.pl ?

    Not sure if it helps or not, but PAR does require that you specify modules used in the code. It can find module dependencies, but not the actual list of modules used/required.

      "Unknown option: MTk" Apparently not... :(

      {UPDATE}: Oops, it's pp -M Tk code.pl. But it still doesn't work :(

      {UPDATE2}: Oho. pp -c dict.pl. Dadah! It works!

      Thanks for all your help!

      --
      s/rant/useful stuff/; print $_;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://353754]
Approved by exussum0
Front-paged by exussum0
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2014-07-25 12:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (171 votes), past polls