title: Beginner - GUI toggle button
body: <p>Can i ask for a little help please? I've created a GUI with a toggle button which toggles the LED ON, LED OFF.</p>
  
  <p>What i would like to do now is add some code to change the text of the button as it toggles between the two states.</p>
  
  <p>I've looked up some examples but I can't quite see how, or where, to add the code to make the button text toggle as well.</p>
  
  <p>Thanks for any help.</p>
  
  <p>My code....</p>
  
  <pre><code># Idle 07_02_LED ON using GUI
  from time import sleep
  
  from Tkinter import *
  
  class App:
  
      def __init__(self, master): 
          frame = Frame(master)
          frame.pack()
          Label(frame, text='Turn LED ON').grid(row=0, column=0)
  
          Label(frame, text='Turn LED OFF').grid(row=1, column=0)
  
          button = Button(frame, text='LED 0 ON', command=self.convert0)
          button.grid(row=2, columnspan=2)
  
  
      def convert0(self, tog=[0]):
  
          tog[0] = not tog[0]
          if tog[0]:
          print('LED 0 OFF')
  
          else:
          print('LED 0 ON')
  
  root = Tk()
  
  root.wm_title('LED on &amp; off program')
  
  app = App(root)
  
  root.mainloop()
  </code></pre>