title: Iterating quicksort steps - visualisation in turtle
body: <p>I'm writing a simple app in <code>Python3</code> with <code>Turtle</code>. It visualizes <code>quicksort</code> algorithm. I want to improve my app so I can show each step of the algorithm by waiting for a click from user.</p>
  
  <p>I've tried simple <code>input()</code> in the middle of the algorithm but this requires the console to be active while the app window goes to the background.
  Now I'm trying to use <code>onscreenclick()</code> but when algorithm goes to certain point, it stops listening for mouse events.</p>
  
  <p>How can I do it? Is there any other way to do this?</p>
  
  <pre><code>def partition(array, start, end):                  
      global clickedFlag
      pivotIndex = start                                  
      pivotValue = array[end]                             
      for i in range(start, len(array) - 1):              
          if array[i] &lt; pivotValue:                       
              if clickedFlag:
                  swap(array, i, pivotIndex)                  
                  pivotIndex += 1                            
                  clickedFlag = False                                     
              else:
                  while clickedFlag == False:
                      onscreenclick(clicked)
                      listen()
      swap(array, pivotIndex, end)                        
      return pivotIndex
  
  def clicked(x,y):
      global clickedFlag
      clickedFlag = True
      return clickedFlag
  </code></pre>