Tkinter activate window on Windows XP

北城以北 提交于 2019-12-06 05:00:51

Unfortunately, after a week there have been no answers and I was not able to find a direct way to do this with Tkinter. I did find a way to solve the problem though and it appears to work consistently. Here are the steps I took to make the screens activate:

  • Install pywin32.
  • Create a function that activates the tk app.
  • Create a function that activates the 5250.

Then each time I do a iconify/deiconify I also run the function to activate the appropriate screen. The code that activates the tk window looks like this:

def activate_self(self):
    """ Activate this window. """
    shell = win32com.client.Dispatch('WScript.Shell')
    shell.AppActivate(str(self.title))
    shell = None

The code that activates the caller is a little ugly since it has to guess the title but is the same basic concept.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!