in reply to Tk:: Graph menu not working to change the type of graph

Hi wishartz,

A couple of suggestions:

First, please include the entire program.  What you've supplied is apparently only subroutines; there is no use Tk, nor use Tk::Graph, and no program main from which any of the subroutines are called.

Secondly, please provide a program which *works*.  When I make the assumption that you're trying to call reportg(), I get the following:

#!/usr/bin/perl use Tk; use Tk::Graph; reportg(); # The rest of your code as you provided it... # # Output # Tk::Error: Can't set -variable to `undef' for Tk::Graph=HASH(0x84c9780 +): Tie::Watch::new(): -variable is required. at /usr/lib/perl5/site_p +erl/5.8.0/Tk/Graph.pm line 1088 at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk/Derived. +pm line 294 Tk callback for . Tk::Derived::configure at /usr/lib/perl5/site_perl/5.8.0/i386-linux-t +hread-multi/Tk/Derived.pm line 306 main::reportg at x line 72 ERROR in Tk::Graph:Tk::Graph::set #947: Option '-type' is incorrect! ( +) at /usr/lib/perl5/site_perl/5.8.0/Tk/Graph.pm line 1802. Can't set -variable to `undef' for Tk::Graph=HASH(0x84c9780): Tie::Wat +ch::new(): -variable is required. at /usr/lib/perl5/site_perl/5.8.0/T +k/Graph.pm line 1088 at /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Tk/Derived. +pm line 294

Thirdly, please put the following statements at or near the top of your code:

use strict; use warnings;

They will alert you to variables which have not been declared, which is a GOOD THING!

For example, when I did that to your program, I needed to then define the following variables (under the section "Global data"):

#!/usr/bin/perl # Use Strict! Use Warnings! #use strict; #use warnings; # Libraries use Tk; use Tk::Graph; # Global data #my $data; #my $MW; #my $total_user_job_count; #my $usage; #my $ca; #my $typ; #my $field; # Main program reportg();

Once you provide a working example which anyone else can run, to get the errors you describe, it will be much easier to identify your problem!


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Tk:: Graph menu not working to change the type of graph
by wishartz (Beadle) on Sep 27, 2006 at 15:36 UTC
    Unfortunatley, I can't really supply the entire program because you will need the data files to run it, which I'm not allowed to give out. Sorry about that, I know it makes it harder to find the problem. I have put in the statements use Tk; and use Tk::Graph at the start of the program and the program does display a graph with the correct values, so I know that part of the program works ok. It's just when I tried changing the type of the graph by using menus, it just doesn't change. It displays a pie chart to start off with, with the correct values, but when I chose a selection on the menu the graph doesn't change and I can see the error that i mentioned before in the console. I know the variable for the type of graph is correct because I'm printing it out when that function is called.
      We don't WANT to see the propritary stuff! WHat we need you do is make us up a compact test case that shows what doesn't work, then we can run it and figure out how to help you.

      In this case what you need to do is give us some dummy data built-into the code.

      jdtoronto