in reply to how Tk wedgets interact?

Ok, what I think you are saying is that you want an input widget that you can type in and a msg area to display output, based on what was typed in the input box.
That's actually very simple:
  • create a mainwindow
  • create an entry widget and a msg widget as children of the window and pack them.
  • bind to the enter key in the entry widget a routine that updates the msg area with the appropriate msg.
    That's it. Here's an example:
    #!/usr/local/bin/perl use Tk; use strict; my $mw = Tk::MainWindow->new(); my $entryv; my $msgv; my $entry = $mw->Entry(-textvariable => \$entryv)->pack(-side => 'top' +,-fill => 'x'); my $msg = $mw->Message(-textvariable => \$msgv)->pack(-side => 'top',- +fill => 'both'); $entry->bind('<Return>',sub {$msgv = uc($entryv)}); Tk::MainLoop();


    -pete
    Entropy is not what is used to be.
  • Replies are listed 'Best First'.
    Re: Re: how Tk wedgets interact?
    by benlaw (Scribe) on Feb 08, 2002 at 07:46 UTC
      oh , thx a lot!

      if there are 2 mainwindow, is it ok?
        IIRC, you can't have 2 main windows. You can create a main window and a toplevel window though. That should work fine.

        -pete
        Entropy is not what is used to be.