title: GUI Button hold down - tkinter
body: <p>I'm trying to do a GUI in python to control my robotic car. My question is how I do a function that determine a hold down button. I want to move the car when the button is pressed and held down and stop the car when the button is released.</p>
  
  <pre><code>from Tkinter import * 
  
  hold_down = False 
  root = Tk()
  
  def button_hold(event):
        hold_down=true
        while hold_down== True: 
                 print('test statement')
                 hold_down = root.bind('&lt;ButtonRelease-1&gt;',stop_motor)
  
  def stop_motor(event):
         hold_down= False
         print('button released')
  
  button = Button(root, text ="forward")
  button.pack(side=LEFT)
  root.bind('&lt;Button-1&gt;',button_forward)
  root.mainloop()
  </code></pre>
  
  <p>I'm trying to simulate what I found in this <a href="https://stackoverflow.com/a/2440643">answer</a></p>
  
  <p>I try to do it in a <code>while</code> loop with a boolean. When the user presses the button the boolean changes to <code>True</code> and code enters the while loop. When user releases the button the boolean changes to <code>False</code> and code exits from loop but in this code the boolean stay always true no matter if I released the button or not. </p>
  
  <p>Edit: I want a function to be called until a condition occurs.The function to be called is hold_down() and the condition to check  is the button is released.</p>
  
  <p>Update: I found a way to make it work.</p>