title: How can I make a script wait for a button press?
body: <p>I apologize if the answer to this question is obvious, but I am unfamiliar with the inner workings of Python.</p>
  
  <p>Basic Scenario: I have a Python script that does stuff. Periodically, when certain conditions are met (like a flag variable being set), I want the script to pause and wait for the user to press a GUI button.</p>
  
  <p>How can I implement this?</p>
  
  <p>To clarify, I want it to work like input() does, in that it pauses everything and waits for the function call to be resolved, except that I don't want it tied to text, but rather a GUI button. I plan on using Tkinter to make the button.</p>
  
  <p>My initial thoughts are making a while loop something like this:</p>
  
  <pre><code>x = 2
  while (x &gt; 1):
      #do nothing
  </code></pre>
  
  <p>And then the button will call a function that sets x = 0</p>
  
  <p>Is this the proper way to do this? Is there a better way? Am i missing something obvious?</p>
  
  <p>Sample Code:</p>
  
  <pre><code>class Displayable(object):
      max_display_level = 1   # can be overridden in subclasses
      manual_step = False     # can be overridden in subclasses
  
      def display(self,level,*args,**kwargs):
          -Do stuff unrelated to the question-
  
          if (self.manual_step):
             if level &lt;= self.max_display_level:
                 input("Waiting for input: ")
  </code></pre>
  
  <p>The idea behind this is objects will extend the class Displayable and set their own max_display_level and manual_step values. A higher max_display_level means more messages will be displayed (ie. if I call display() with levels = 1,2,3, and 4, if my max_display_level ==2, only the first 2 calls will have all the logic executed. It is a way to allow a user to set the level of verbosity of the execution. It's there for a reason which I won't get into, but it should stay.) If a specific object has manual_step == true and the level is satisfied, it should wait for user input when display() is called. The trick is I want it to wait for a button press instead of text+enter.</p>