def applescript(script):
    return subprocess.check_output(['/usr/bin/osascript', '-e', script])

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()
How to make a window jump to the front?