title: Tkinter - update variable constantly, without pressing the button
body: <p>So here's my python script:</p>
  
  <pre><code>from Tkinter import *
  #import RPi.GPIO as GPIO
  
  #GPIO.setmode(GPIO.BOARD)
  #GPIO.setup(12, GPIO.OUT)
  
  #p = GPIO.PWM(12, 50)
  #p.start(0)
  
  def cmd():
     speed = "Rotor speed= " + str(var.get())
     label.config(text = speed)
     #dc = int(var.get())
     #p.ChangeDutyCycle(dc)
  
  tk = Tk()
  var = DoubleVar()
  scale = Scale(tk, from_=100, to=0, variable = var)
  scale.pack(anchor=CENTER)
  button = Button(tk, text="Set speed", command=cmd)
  button.pack(anchor=CENTER)
  label = Label(tk)
  label.pack()
  
  tk.mainloop()
  
  print("Closing the program and cleaning up the GPIO")
  #p.stop()
  #GPIO.cleanup()
  </code></pre>
  
  <p>Some parts are commented out for now because I'm working on the code on my PC and not the Raspberry Pi. I left them for the context.</p>
  
  <p>So This code creates a very simple GUI for my helicopter. It works just fine, but to change the duty cycle of my PWM pin (<code>cmd()</code> function) I have to press the button. </p>
  
  <p>I tried to make my program check for the value of the slider automatically but I just can't figure it out.</p>
  
  <p>Any ideas how could I change this code to change the value of <code>dc</code> along with the slider movement, without having to press the button to update it?</p>