code: def ok(self, event=None):
          
          if not self.validate():
              self.initial_focus.focus_set()  # put focus back
              return
  
          # NOTE(amin): Using self.withdraw() here causes the
          # ui to hang until the window loses and regains
          # focus. There must be some blocking operation going
          # on, but after some digging, I haven't been able to
          # get any leads.
  
          # NOTE(amin): We must clear the main window's entry
          # before returning focus to it. Otherwise, rapid
          # pressing of the enter key will open multiple dialogs.
          self.entry_to_clear.delete(0, 'end')
  
          self.update_idletasks()
  
          try:
              self.apply()
          finally:
              self.cancel()
docs: This method is identical to tkinter.simpledialog.Dialog.ok(),
          but with 'self.withdraw()' commented out.