Loading ...
Sorry, an error occurred while loading the content.

TK - Arrays

Expand Messages
  • Chirhart, Brian
    I have a program that I am writing that will open several windows. There is no real limit as to the number of windows someone may open. I want to give each
    Message 1 of 1 , Apr 19, 2002
    • 0 Attachment
      I have a program that I am writing that will open several windows. There is
      no real limit as to the number of windows someone may open. I want to give
      each window it's own variable, yet not have to write separate code for each
      window. I was wondering if there is a way to assign an array to a Tk widget
      instead of a scalar variable.

      My code that I thought would work is:

      use Tk;
      my $x = 0;
      for $x ($x = 0 .. 5) {
      my $mw[$x] = new MainWindow;
      my $butGraph = $mw[$x]->Button(-text => "Exit",
      -command =>
      \&ExitGraph)->pack(-anchor => 'w');
      #$x++;
      }


      MainLoop;

      sub ExitGraph {
      $mw[$x]->destroy();
      }

      but alas - it does not. Any ideas?
    Your message has been successfully submitted and would be delivered to recipients shortly.