accessing MainWindows widget after the user clicks the X (close) button 
Author Message
 accessing MainWindows widget after the user clicks the X (close) button
I have a Text widget that is owned by the MainWindow.
When the user clicks the "X" button at the top to close the application
I want to be able to intercept that and before the MainWindow is destroyed
access the Text widget to write out what is in it to a file, before closing.

How do I accomplish that?

jerry
--
Try Linux, the Operating System which values your freedom.
Not the Outlaw Microsoft, which values their bottom line.
---

perl -e 'print pack("H*","6a6664656364406578656370632e636f6d");'
or
perl -e 'print unpack("u", "2:F9D96-D0&5X96-P8RYC;VT*");'
-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the




Sun, 28 Mar 2004 09:50:04 GMT  
 accessing MainWindows widget after the user clicks the X (close) button


Quote:
>I want to be able to intercept that and before the MainWindow is destroyed
>access the Text widget to write out what is in it to a file, before closing.

Try looking at the protocol method in Tk::Wm; you probably want to set
a callback for WM_DELETE_WINDOW.


Sun, 28 Mar 2004 10:31:07 GMT  
 accessing MainWindows widget after the user clicks the X (close) button
Consult the Tk::Wm man page.  There's a method described in there that allows
you to receive messages from the Window manager, such as the close box being
hit.  However, it describes the widgets as have this method TopLevel widgets.
  Your text widget may have to be a child of one of a top level to bring this
off.  However I believe it would look something like this:

$topLevel->protocol('WM_DELETE_WINDOW', \&close_window() ;) ;


Quote:
> I have a Text widget that is owned by the MainWindow.
> When the user clicks the "X" button at the top to close the application
> I want to be able to intercept that and before the MainWindow is destroyed
> access the Text widget to write out what is in it to a file, before
> closing.

> How do I accomplish that?

> jerry

-++**==--++**==--++**==--++**==--++**==--++**==--++**==
This message was posted through the Stanford campus mailing list
server.  If you wish to unsubscribe from this mailing list, send the



Sun, 28 Mar 2004 10:27:31 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. accessing MainWindows widget after the user clicks the X (clo

2. binding right mouse button click to all buttons

3. Close all MainWindows + cleanup per MainWindow

4. Right-clicking buttons in Perl/TK

5. avoid double-click on submit button

6. error grabbing button click

7. Disable button when clicked?

8. Modifying a button click with the keyboard?

9. Click on a Button does not work

10. Click on a Button does not work

11. Text Widget - removing right-click menu

12. Text widget double-click

 

 
Powered by phpBB® Forum Software