title: create a button that can only be pressed once
body: <p>i am trying to create a button that can only be pressed once for a game in python but i cant figure out how to set a variable that works in the def and does not change every time the function is run.</p>
  <pre><code>tut = turtle.Screen()._root
  def bt1():
      pressed = 1
      x_turn = True
      if (pressed == 1):
          if (x_turn is True):
              print(&quot;this button has not been pressed as player1&quot;)
              x_turn == False
              pressed = 0
          else:
              print (&quot;this button has not been pressed as player2&quot;)
              pressed = 0
              x_turn == True
      else:
          print(&quot;this button has been pressed&quot;)
  
  photo1 = Image.open(r&quot;C:\image.png&quot;)
  resize_photo1 =photo1.resize((50,50), Image.ANTIALIAS)
  print_photo1 = itk.PhotoImage(resize_photo1)
  Button(tut, image= print_photo1,command=bt1).pack(side= LEFT)
  </code></pre>