Re: (Auto)Timeout option for Tk::DialogBox

Slaven Rezic <[email protected]> 11 Jul 2007 00:50:54 +0200
Newsgroups gmane.comp.lang.perl.tk
Message-ID <[email protected]>
[email protected] writes:

> Hi,
> 
> i'd like to propose/submit a patch for Dialogbox.pm
> 
> Reason:
> 
> a) If  using the DialogBox for low-prio infos in an application where there are a lot of different parallel open windows,
> user sometimes shuffled the normal DBox somewhere in the background and since they did not close the box correctly the app seems to hang
> 

Maybe a better solution would be to just make sure that the dialog
stays on top? To accomplish this in Tk you can use

    $toplevel->attributes(-topmost => 1)

. (This should work in Windows since Tk804.something and for X11 you
need the development version and a modern window manager like Metacity
or KDE's wm)

> b) If the App shall show some transient information (which is only a
> short time relevant) and a Dialogbox shall be shown to draw users
> interest

This can easily be done using

   $dialogbox->after($millis, sub { $dialogbox->Exit });

just before the ->Show call.

(The Tk::DialogBox::Exit method is not documented, but probably should).

> 
> Function:
> The attached patch for the DialogBox will make it either wait for the user to press any of the available buttons as before or after reaching an optional timeout-time the box will silently withdraw by simulating a pressed default button.
> 
> Please feel free to apply this patch into the current Tk svn repository and/or let me have some feedback.
> 

I don't think the patch should go into Tk, as this functionality can
easily be achieved with the above mentioned two lines of code.

Regards,
        Slaven

-- 
Slaven Rezic - slaven <at> rezic <dot> de

    tksm - Perl/Tk program for searching and replacing in multiple files
    http://ptktools.sourceforge.net/#tksm
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk