title: Python tkinter, tkinter.askdirectory() returns the initial default directory when user hits 'cancel' or X out, or Esc the window
body: <p>No matter what I do, <code>tkinter.filedialog.askdirectory()</code> returns the initial default (current directory) when the <code>Cancel</code> button, or the <code>X</code> close button on the window, or if the user selects <code>Esc</code>. I tried coding the option for an initial directory to <code>C:\</code>, rather than <code>E:\</code> where the script is saved, to try to control this. However, if <code>Cancel</code>, <code>X</code>, or <code>Esc</code> is selected, it still returns <code>E:\</code>.  I also tried adding the <code>root.protocol</code> to force the <code>X</code> to close the entire program, but it did not change the behavior. I initialized the directory with an empty string, which also had no effect. All the documentation, and question/answers I find, simply state that it should return an empty string in these cases. I need this to be true! I cannot see what is wrong here; thanks in advance for any advice. The only hint I have - is I am unsure how tkinter message and file dialogs use, or if they use, the root window. I think this is where I may be losing control...??</p>
  <p>I am on Windows 10, using Python 3.7.0.</p>
  <p>Here is a toy example of what I have:</p>
  <pre><code>import os
  import tkinter
  import tkinter.filedialog as tkf
  
  class Directory(tkinter.Tk):
      def __init__(self):
              
          self.root = tkinter.Tk()
          self.root.protocol(&quot;WM_DELETE_WINDOW&quot;, self.root.quit())
          self.root.withdraw()
  
          self.directory = &quot;&quot;
          
         
      def GetDirectory(self):
          self.directory = os.path.abspath(tkf.askdirectory(master = self.root, initialdir = 'C:\\', title = &quot;Select your Source directory&quot;)) 
          print('type directory', type(self.directory), self.directory==&quot;&quot;, self.directory)
        
          return self.directory
  
  if __name__ == &quot;__main__&quot;:
      app = Directory()
      Directory.GetDirectory(app)
  
  Output after hitting cancel, Esc, or X:
  
  type directory &lt;class 'str'&gt; False E:\
  </code></pre>