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