title: How to make buttons to be only clicked once using Tkinter in Python?
body: <p>So I made a sill calculator that just takes an input of 'banana' and 'milk' when the user does such calculation: banana + milk, then it returns 'banana milk' and so on. Since these strings are not a number, I want the buttons to be only clickable once so that it will never be 'banana banana + milk' but only 'banana + milk' or 'milk + banana'... </p>
  
  <p>Also, whenever the user puts only one input such as 'banana' and press Enter (finalPress), I want to print out only 'banana', but with my code, it goes to <strong>elif phrase[0] == 'Banana':</strong> and prints out 'banana milk' even though I only press 'banana'. How can I fix this issue?</p>
  
  <p>Below is my code:</p>
  
  <pre><code>from tkinter import *
  
  phrase = []
  phrase_string = ''
  
  
  # To press any button
  def press(item):
      global phrase, phrase_string
      if item == 'Banana':
          phrase.append('Banana')
      elif item == 'Milk':
          phrase.append('Milk')
      elif item == 'AND':
          phrase.append(' and ')
  
      phrase_string = ''
      for ele in phrase:
          phrase_string += ele
      return equation.set(phrase_string)
  
  
  # This is enter
  def finalPress():
      global phrase, phrase_string
      if phrase[0] in ['Banana', 'Milk'] and len(phrase) is 1:
          phrase = phrase[0]
      elif phrase[0] == 'Banana':
          if phrase[1] == ' and ':
              phrase.clear()
              phrase = 'Banana Milk'
      elif phrase[0] == 'Milk':
          if phrase[1] == ' and ':
              phrase.clear()
              phrase = 'Milk Banana'
  
      return equation.set(phrase)
  
  
  # Clear the content
  def clearContent():
      pass
  
  
  # Driver code
  if __name__ == '__main__':
      # create application window
      app = Tk()
  
      # title
      app.title("Slly Calculator")
  
      # geometry
      app.geometry('290x162')
  
      # background color
      app.configure(bg='pink')
  
      equation = StringVar()
      windows = Entry(app, textvariable=equation)
      windows.grid(columnspan=5, ipadx=100, ipady=10)
      equation.set('Press Buttons Please')
  
      # Create buttons and other accessories
      button1 = Button(app, text=' Banana ', fg='yellow', bg='purple',
                       command=lambda: press('Banana'), height=2, width=10)
      button1.grid(row=2, column=0, sticky="NSEW")
  
      button2 = Button(app, text=' Milk ', fg='brown', bg='pink',
                       command=lambda: press('Milk'), height=2, width=10)
      button2.grid(row=2, column=1, sticky="NSEW")
  
      plus = Button(app, text='AND', fg='black', bg='white',
                    command=lambda: press('AND'), height=2, width=10)
      plus.grid(row=4, column=0, sticky="NSEW")
  
      equal = Button(app, text='ENTER', fg='black', bg='white',
                     command=finalPress, height=2, width=10)
      equal.grid(row=4, column=2, sticky="NSEW")
  
  # start the GUI
  app.mainloop()
  </code></pre>
  
  <p>Thank you so much! :-D</p>