PDL 2.4.3 and Tk seem to play well together -- but you have to load Tk *before* PDL, I guess because of some of the strangeness that Tk uses in its load process. (PDL is pretty strange too but it doesn't hold a candle to the involuted module loading that Tk does).

I agree with Jarle that those look like shell error messages rather than perl error messages: you will want to make sure that your metavis.pl has a correct shebang in it, or else call perl explicitly as in
        `perl metavis.pl`;
if you are using the backtick syntax.

If you want to run a perl/PDL task and still be able to update widgets, you can use the ALARM signal to keep Tk running - like so:

        $pid = fork();
        die "couldn't fork" unless ($pid>=0);
        if($pid) {
                # PARENT: go into an infinite loop and kick the child every 0.1 
sec     
                sleep 1; # allow some settling time.
                while(1) {
                        select(undef,undef,undef,0.1); # sleep 0.1 second
                        kill 14, $pid;                 # Wake up the other 
process
                }
                exit(0);
        }

        # CHILD: set up a handler for the ALARM signals we'll be expecting
        $SIG{'ALRM'} = sub { $mainwindow->idletasks; };

        #...rest of code here...

That forks the process and transfers the main effort to the daughter. The parent just goes into an infinite loop, waking up the daughter every tenth of a second and making it run the idletasks method on the main Tk window. Then you can code up your intensive data handling operation and widgets will still get updated as it is happening. (Caveat: the alarm signal won't interrupt an atomic PDL operation, so if you are (e.g.) Fourier transforming a megapixel image, widgets won't update while that is happening, but they will as soon as the FFT finishes.)

Best of luck,
Craig




On Nov 14, 2006, at 7:35 AM, Jarle Brinchmann wrote:

Hi Dimitar,

I haven't tried running Tk scripts within perldl - there might be problems associated with this, but it could also be that your script does not include a she-bang '#!/usr/bin/perl' in the beginning and gets executed as a shell script?

Anyway, an alternative I use relatively often is the 'do' command:

 perldl> do 'metavis.pl'

in your case it might not do what you want though, not sure whether it will provide the prompt for you or not...

                        Cheers,
                                Jarle.



Dimitar Kenanov wrote:
Hello guys,
i have a question concerning both PDL and TK. I make a GUI in Perl/ Tk for a program which uses PDL for the matrix calculations. Out of the PDL program comes output which can be further investigated. So i make some scripts for doing this and will include them in the GUI like buttons but i would like to give the user the chance to do himself investigation of the result using himself the PDL. So i would like to have in a TAB or separate window of TK a running PDL instance. I have seen i can run scripts and commands out of pdl together with "&" which would be the perfect solution i thought but then i tried and got some error messages:
perldl> #metavis.pl
./metavis.pl: line 2: use: command not found
./metavis.pl: line 3: use: command not found
./metavis.pl: line 4: use: command not found
./metavis.pl: line 5: use: command not found
./metavis.pl: line 6: use: command not found
./metavis.pl: line 7: use: command not found
./metavis.pl: line 8: use: command not found
./metavis.pl: line 9: use: command not found
./metavis.pl: line 10: use: command not found
./metavis.pl: line 11: use: command not found
./metavis.pl: line 13: =MainWindow-: command not found
./metavis.pl: line 14: syntax error near unexpected token `('
./metavis.pl: line 14: `$mw->geometry("500x300");'
When i tried to run the script with "pdl -tk -f metavis.pl" command line it was functioning well only i didnt have the pdl propmt free to use.
I would appreciate any kind of help on the subject.
Thank you for your attention and time.
Greetings
Dimitar

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl



_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to