code: def _unfocus(self, event):
          
          w = self.focus_get()
          if w != self and 'spinbox' not in str(w) and 'entry' not in str(w):
              self.focus_set()
docs: Unfocus palette items when click on bar or square.