title: Waiting inside a for loop for button click in Tkinter
body: <ol>
  <li>I am trying create a for loop based on the decimal value of the option menu button.</li>
  <li>If the option button chosen is 2, then the for loop circulates for two times.</li>
  <li>But the for loop needs to wait until the button created inside the for loop gets clicked.</li>
  <li>Below code shows the same. 
  
  <ul>
  <li>Option menu has range of 1 to 10 i.e. user can choose 1 to 10 device to be created. </li>
  <li>The moment the option menu is choose, the command button for the option menu gets operated i.e. comp_gt_data.</li>
  <li>This basically circulates in a for loop to take the configuration of the N number of devices. </li>
  <li>Once after taking the configuration for the 1st device, I create a "Enter the Next Device Configuration" button inside the for loop and wanted the button to be clicked to take the next device configuraiton.</li>
  <li>But the "Enter Next Device ...." button is not getting created and keeps circulating in while loop.</li>
  <li>I tried using time.sleep(60) but still didn't work.</li>
  <li>The "Enter Next Device.." basically tries to clear the old device configuration and tries to set cvadt_val_loop_exit=0 so that the while loop can exit.</li>
  <li>QUERY: HOW TO Basically wait inside a for loop for a button to be clicked to proceed further?  </li>
  </ul></li>
  </ol>
  
  <p><br></p>
  
  <pre><code>self.cvo1 = OptionMenu(root, cvagt_val, *cvagt_list, command=self.comp_gt_data)
      self.cvo1.pack()
  def comp_gt_data(self, *args):
      if cvagt_val.get()!=0:
          cvagt_val_loop = cvagt_val.get()
          for cvagt_loop in range(1, cvagt_val_loop+1):
              self.cvad_l0 = Label(root, text="Enter the %d Device Config"% cvagt_loop)
              self.cvad_l0.pack()
              self.cvad_l1 = Label(root, text="How Many D~S You Want To Create: ")
              self.cvad_l1.pack()
              self.cvad_e1 = Entry(root)
              self.cvad_e1.pack()
              self.cvad_l2 = Label(root, text="How Many MS You Want To Create: ")
              self.cvad_l2.pack()
              self.cvad_e2 = Entry(root)
              self.cvad_e2.pack()
              self.cvad_l3 = Label(root, text="How Many SD You Want To Create: ")
              self.cvad_l3.pack()
              self.cvad_e3 = Entry(root)
              self.cvad_e3.pack()
              if cvagt_loop &lt; cvagt_val_loop:
                  if not (self.cv_next_dev_cfg_button):
                      self.cv_next_dev_cfg_button = Button(root, text="Enter Next Device Configuration", command=self.cv_next_dev_cfg_button_code)
                      self.cv_next_dev_cfg_button.pack()
                  # Waiting For cvadt_val_loop_exit bit to get set when the cv_next_dev_cfg_button is clicked but its not happening and circulating in the while loop
                  cvadt_val_loop_exit = 1
                  while(cvadt_val_loop_exit):
                      print "Waiting For Next Device Config Button To Be Hit"
                      time.sleep(60)
              else:
                  self.cv_next_dev_cfg_button_code()
                  if not (self.return_button):
                      self.return_button = Button(root, text="Return To Main Menu", command=self.return_button_code)
                      self.return_button.pack()
      else:
          print "Choose Atleast One Device To Create"
  def cv_next_dev_cfg_button_code(self):
      if (self.cvad_l0):
          self.cvad_l0.pack_forget(); self.cvad_l0.destroy(); self.cvad_l0 = None
      if (self.cvad_l1):
          self.cvad_l1.pack_forget(); self.cvad_l1.destroy(); self.cvad_l1 = None
      if (self.cvad_l2):
          self.cvad_l2.pack_forget(); self.cvad_l2.destroy(); self.cvad_l2 = None
      if (self.cvad_l3):
          self.cvad_l3.pack_forget(); self.cvad_l3.destroy(); self.cvad_l3 = None
      if (self.cvad_e1):
          self.cvad_e1.pack_forget(); self.cvad_e1.destroy(); self.cvad_e1 = None
      if (self.cvad_e2):
          self.cvad_e2.pack_forget(); self.cvad_e2.destroy(); self.cvad_e2 = None
      if (self.cvad_e3):
          self.cvad_e3.pack_forget(); self.cvad_e3.destroy(); self.cvad_e3 = None
      if (self.cv_next_agt_cfg_button):
          self.cv_next_agt_cfg_button.pack_forget(); self.cv_next_agt_cfg_button.destroy(); self.cv_next_agt_cfg_button = None
      cvadt_val_loop_exit = 0
  </code></pre>