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

Ah -- well, that's not what I would call an "exit from MainLoop"... I'd call that (i.e. hitting the "X" button on the outer frame of the window) something like "killing the process window".

I thought there might be a way to attach a callback sub (like the one in my reply) to the "Destroy" event for the text widget -- but I just tried that on my mac (where the "quartz" window manager puts its own frame with a "close" button around every X-windows-based Perl/Tk app), using  $text->bind("<Destroy>", sub { ...} ); and it didn't work. :(

update: So, if the rest of your larger script is not GUI-based, and you're just popping up a window when some user input is needed, then yeah, I'd say "$main->destroy" instead of "exit(0)" in my callback on the Button widget, for sure.

Replies are listed 'Best First'.
Re^4: Grabbing Text widget's contents after MainLoop
by GrandFather (Saint) on Jul 22, 2005 at 09:20 UTC

    I added a Cancel button that used exit so your post was by no means in vain. I also used anon subs, but that was my own independent mod of pg's code.

    Thanks for the help.


    Perl is Huffman encoded by design.