Bring window to front in Tk GUI in Windows

Posted on 2011-05-05
Last Modified: 2012-08-13
I have some code that uses Tk. It launches a word document then closes it. Problem is when it closes the word document the tk window falls back to where other apps are on top of it. I need the tk window to be the top most window after the word document closes. I tried focus, grab, etc... and I haven't found any way in windows to bring the tk window in front of all other windows so its in the users face. Thanks! Any advice or simple code I can add to do this?

use Tk;
$mw = MainWindow->new();

#Open document....
#Does some stuff....
#Close Document....
#Now I want the $mw to jump out in front of the users face on top of all other windows whether they are Tk perl related or lets say firefox, internet explorer, excel, etc....

Open in new window

Question by:KGNickl
    1 Comment
    LVL 13

    Accepted Solution

    I've never used it before, but there appears to be a module for that:

    Even if you don't use the module, you might be able to look at the source code and find a way that works for you.

    The basic approach I would try is to turn on the "stay on top" feature for your window (which should force your window to the top), then immediately turn that off (unless you have a good reason to keep it on).

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now