Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: tk question: strick app cann't close by clicking

by BlueBlazerRegular (Friar)
on Apr 24, 2002 at 20:33 UTC ( [id://161779]=note: print w/replies, xml ) Need Help??


in reply to tk question: strick app cann't close by clicking

Check page 243 of "Mastering Perl/Tk", specifically the 'Window Properties' section.

Assigning a empty sub to the WM_DELETE_WINDOW callback turns the button off - like so:

$mw->protocol( WM_DELETE_WINDOW, sub{} );

You'll need to turn off strict subs, as it doesn't like the bareword WM_DELETE_WINDOW. Although I'm sure there is a way of getting around that - I just don't know it...

Replies are listed 'Best First'.
Re: Re: tk question: strick app cann't close by clicking
by benlaw (Scribe) on Apr 25, 2002 at 03:15 UTC
    REALLY Thx BlueBlazerRegular !! ^O^
    I can fully control the window widget ~!
    Really i don't understand what 'protocol' is talking about when i read it before~Thx :D
(ichi) Re x 2: tk question: strick app cann't close by clicking
by ichimunki (Priest) on Apr 25, 2002 at 18:38 UTC
    Great trick. What it really does is capture the signal sent by clicking the close button and smother it. This prevents the button from working, but doesn't necessarily make it go away (it doesn't on the Windows machine I am using just now)-- which as a user-interface thing is bad. The user who tries to click the close button may actually become frustrated and close the window some other way. Or they may just think the programmer is incompetent. ;)

    By the way, you can get around the bareword issue by simply quoting: "WM_DELETE_WINDOW".
      Thanks ichimunki, for the help on the bareword issue. And I agree with you - if you re-direct the close button, you should do something with it, rather than just ignoring the darn thing.

      Normally, I have my 'clean up' sub-routine right after the 'MainLoop', so if when they click on the close button it'll go there by default. This 'clean up' routine is also called by the 'Quit' button (or menu item).


      And on a completely different subject - I've found that when you try to plug someone's username into the reply, make sure you have their id right. Or else you get links to some interesting locations...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://161779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found