def procidset():
    return set(applescript(
        'tell app "System Events" to return id of every process whose name is "Python"'
        ).replace(',', '').split())
idset = procidset()
root = Tkinter.Tk()
procid = next(iter(procidset() - idset))
applescript(
    """
    tell app "System Events"
        repeat with proc in every process whose name is "Python"
            if id of proc is """
     + procid +
    """ then
                set frontmost of proc to true
                exit repeat
            end if
        end repeat
    end tell"""
    )
How to make a window jump to the front?