in reply to Tk:Photo -data with binary data?

Consider the following tcl/tk program which works correctly:

#!/usr/bin/wish set fdata [read [open "test.gif"]] label .l1 -image [image create photo -format gif -data $fdata] pack .l1

A similar Perl/Tk program dies on the same .gif with various errors. I got:

no image data for this index at /usr/lib/perl5/Tk/Image.pm line 21, <G +IF> line 1.

and

Segmentation fault

I have the Debian (etch) system shipped perl (5.8.8). Tk is 804.027, also system.

Update: tcl/tk is 8.4.12

Replies are listed 'Best First'.
Re^2: Tk:Photo -data with binary data?
by BrowserUk (Patriarch) on Nov 29, 2006 at 11:00 UTC

    I have the feeling that this post is telling me something profoundly significant, but I'm not sure what it is?

    Are you saying that it's the perl/tk wrappers that are broken not the underlying tcl/tk code?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      perl/Tk do not have underlying Tcl/Tk code, because it is a full migration of tcl/Tk to Perl, with some possible mistakes in the middle.

      So it is quite possible for some feature to being improved in Tcl/Tk but is stale in Perl/Tk.

      I beleive you'll got that snippet of your code working via Tcl::Tk, which provides Tcl/Tk with perl/Tk syntax; but this module do not maintain 100% compatibility of perl/Tk syntax, however.
      But you'll have a possibility to use those Tcl/Tk libraries lacking in perl/tk

        Thanks, but I been here before. I just downloaded Tcl::Tk and tried to build it

        c:\Perl\packages\Tcl-Tk-0.92>makefile 'tclsh' is not recognized as an internal or external command, operable program or batch file. Your Tcl installation (tclsh) fails to find Tk package. One of possible reasons is missing file 'pkgIndex.tcl' in ..../tk8.4/ directory; Please check if you can feed 'package require Tk' to tclsh

        At that point, I read the cpan docs and there is no mention of any dependancies, never mind where i might obtain them.

        So I look into the readme and it says

        Normally you just make sure you have right tcl/tk in your path at a moment of running Makefile.PL script.

        But again, there is no mention of what 'tcl/tk' is, never mind where I would have to go to get it, or what pain is going to be involved in trying to build it for win32.

        I just want to be able to throw a couple of images onto my screen and 'flicker compare' them. I'm trying to analyse some large chunks binary data, and this is a technique I've used before with great success.

        My point is, I've no interest in building fancy guis, nor do I wish for the distractions of trying to get yet another 'never intended for windowz' package to build on my system.

        That's why I tried Tk--it's already installed. It's also why I'll look into win32::GUI. I did once get GTK2 built on my system, but the first time I upgraded Perl, it broke and the memory of all the pain involved in tracking down the huge list of dependancies and working out how to build them puts me off from trying again.

        This is why I tend to use binary distributions wher they are available most of the time. It's not that I cannot work out how to do these things. It's that I am in the middle of something and don't want to be distracted from it spending days and weeks trying to resolve these kinds of problems. Especially when it involves learning yet another set of apis and bindings, and it'll all fall in a heap and have to be repeated then next time I unpgrade Perl.

        Please don't misunderstand me. I've seen several positive references to tcl/tk on PM over the last couple of years, and I'm sure that it's a brilliant package. One day Real Soon Now I'll set aside time for working out what it it, where it is, and what else I need to make it build and run, but right now I just want to be able to flicker compare a couple of images I produce with GD. A quick scout of what's available for Win32::GUI tells me that isn't going to be trivial either, so I'll probably settle for the easy option of outputting the images to files and using a image viewer to flick between them.

        Unfortunately, this is pretty indicative of the whole Perl/CPAN experience. Individually, modules tend to do what they do pretty well. The problems arise when you try to use two or more together in a single app. The disconnect between them--Tk and GD in this case--means that you end up having to perform twice as much work as should be necessary in converting data from one format to another.

        I know Perl is defined as a 'glue language', and is great at it, but the lack of a 'joined up architecture' means that you end up using great gobs of glue where a couple of screws would be so much better. I do hope this lesson is learnt when (if?) Perl6 (sorry, read that as "Perl 6"), and CP6AN start to come together.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.