How to put a tkinter window on top of the others?

后端 未结 7 875
北恋
北恋 2020-12-02 23:23

I\'m using Python 2 with Tkinter and PyObjC, and then I\'m using py2app.

The program is working fine, but the window starts a

相关标签:
7条回答
  • 2020-12-03 00:27

    More for mac OS users. Although the above solutions seem to display correctly, the app is still put at "the end of the stack" from the Finder's point of view. As can be seen with the Cmd+Tab switcher, or simply observing that python doesn't get the focus.

    Solution from username fixing it all (again, for mac OS):

    import os
    os.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')
    

    Maybe surround that with something like

    import platform
    if "Darwin" in platform.system():
        # apply fix
    
    0 讨论(0)
提交回复
热议问题