in reply to Re: Grabbing Text widget's contents after MainLoop
in thread Grabbing Text widget's contents after MainLoop

Close, although the empty main window is a bit naff :-)


Perl is Huffman encoded by design.
  • Comment on Re^2: Grabbing Text widget's contents after MainLoop

Replies are listed 'Best First'.
Re^3: Grabbing Text widget's contents after MainLoop
by pg (Canon) on Jul 22, 2005 at 05:11 UTC

    My original solution was sort of over kill, this one is much better and simpler:

    use Tk; use Tk::DialogBox; my $mw = new MainWindow(); my $content; my $text = $mw->Text()->pack(); my $ok = $mw->Button(-text => "OK", -command => \&grab)->pack(); MainLoop; print $content; sub grab { $content = $text->Contents(); $mw->destroy(); }

      Yep, that's pretty good! I had a hazy idea that something like that was required, but I don't know enough Tk yet to figure it out in reasonable time. I find the doucmentation for Tk a bit heavy going and diffuse at the same time.

      Thanks for a good solution.


      Perl is Huffman encoded by design.