in reply to How to access options to Tk widgets

Error messages under Tk usually identify a line number and a stack trace -- were you able to determine if the line that triggered the error was in Populate(), and if so, which variable caused the problem?

It is entirely possible (and very helpful) to do "perl -d" on a script that uses Tk, put a break point in a given callback, and see what the variables really contain when that callback runs.

  • Comment on Re: How to access options to Tk widgets

Replies are listed 'Best First'.
Re: Re: How to access options to Tk widgets
by Spookymonster (Initiate) on May 10, 2002 at 03:34 UTC
    Here's the error message: Use of uninitialized value in concatenation (.) or string at SR/Dtest.pm line 16 (#1) That points to this line:
    $self->Label(-text=>"var= $optnum")->pack();
    If I'm understanding correctly, it indicates $optnum is undefined. If that is so, then the problem must lie with this line:
    my $optnum = $self->optionGet('Target','Dtest');
    I'll crack the books and check into the debugger ASAP.
      I'm far from an expert in Tk, but I've just finished a couple of programs in it for an advanced perl class, so here goes my two cents. :)

      Is there a reason you have

      $self->Label(-text=>"var= $optnum")->pack();

      instead of

      $self->Label(-text=>$optnum)->pack();

      If you're actually trying to make your text label $optnum, I believe that you need -text=>$optnum.

      Hope that helps!

      p.s.

      If you find something to debug Tk, let me know would you? I had a HELL of a time debugging my Tk stuff beyond the print a line type of debugging.

        Tk has a built-in debugger that comes with the standard distro. When debugging, type perl -d:ptkdb name_of_app - it brings up a graphical debugger. I've found it easy to use and very helpful when building Tk apps.


        Rich36
        There's more than one way to screw it up...

      A reply falls below the community's threshold of quality. You may see it by logging in.