def _shake(root, callback, frame=0):
    "Animate each step of shaking the root window."
    frame += 1
    # Get the window's location and update the X position.
    x, y = map(int, root.geometry().split('+')[1:])
    x += round(math.sin(math.pi * frame / 2.5) * \
               math.sin(math.pi * frame / 50) * 5)
    root.geometry('+{}+{}'.format(x, y))
    if frame < 50:
        # Schedule next step in the animation.
        root.after(20, _shake, root, callback, frame)
    else:
        # Enable operations after one second.
        callback()
Animate each step of shaking the root window.
recipes/Python/578154_Directory_Pruner_4/recipe-578154.py