def cycle():
    global switcher
    canvas.tag_raise('bg')
    if switcher:
        ball2.ball_update()
        ball2.ball_update()
        canvas.tag_raise('ball')
    else:
        ball.ball_update()
        ball.ball_update()
        canvas.tag_raise('ball2')
    tab8.update_idletasks()
    switcher = (not switcher)
    tab8.after(40, cycle)
def cycle():
    global switcher
    canvas.tag_raise('bg')
    if switcher:
        ball2.ball_update()
        ball2.ball_update()
        canvas.tag_raise('ball')
    else:
        ball.ball_update()
        ball.ball_update()
        canvas.tag_raise('ball2')
    tab8.update_idletasks()
    switcher = (not switcher)
    tab8.after(40, cycle)