title: Python - Creating a flag to check if a button was clicked is not working
body: <p>I'm using appJar to create a GUI and I'm trying to check if a button was clicked or not, so I thought of creating a flag to do that, however it does not work as I expected. I want the program to do the following: </p>
  
  <p>Scenario 1:<br>
  1- Load dictionary<br>
  2- 'Replace' button clicked > dictionary is not updated</p>
  
  <p>Scenario 2:<br>
  1- Load dictionary<br>
  2- 'Update dictionary' button is clicked > set flag to 'yes'<br>
  3- 'Replace' button clicked > <strong>reload</strong> dictionary</p>
  
  <p>My code:</p>
  
  <pre><code># defined flag globally
  global flag
  flag = 'no'
  
  # Function to change the global var -flag-
  def anyUpdate(f):
      if f == 'yes':
          flag = f # change global variable -flag- to 'yes'
          return True
      else:
          return False
  
  def press(btn):
      # Edit dictionary clicked
      if btn=="Update dictionary":
          anyUpdate('yes') # call function - 'yes' sent
  
      # Replace clicked
      if btn=="Replace":
          if someNotImportantCode:
              someCode
          else:
              print flag # prints 'no' even if update dictionary clicked means global var didn't change
              checkUpdate = anyUpdate(flag) # call function - global var sent
              print checkUpdate # prints False of course since flag is 'no'
              if checkUpdate == True:
                  # reload dictionary
                  reps = getDictionary()
  </code></pre>
  
  <p>As you see the global flag doesn't change. I feel my idea isn't very good, but I've tried different codes nothing is working for me and I feel stuck. Any help?</p>