code: def select_directory(self):
          
          basedir = to_text_string(self.wd_edit.text())
          if not osp.isdir(basedir):
              basedir = getcwd_or_home()
          directory = getexistingdirectory(self, _("Select directory"), basedir)
          if directory:
              self.wd_edit.setText(directory)
              self.dir = directory
docs: Select directory