title: How to select a directory and store the location using tkinter in Python
body: <p>I am creating a GUI with a browse button which I only want to return the path. I've been looking at solutions using code like below. </p>
  
  <pre><code>Tkinter.Button(subframe, text = "Browse", command = self.loadtemplate, width = 10).pack()
  
     def loadtemplate(self): 
          filename = tkFileDialog.askopenfilename(filetypes = (("Template files", "*.tplate")
                                                               ,("HTML files", "*.html;*.htm")
                                                               ,("All files", "*.*") ))
          if filename: 
              try: 
                  self.settings["template"].set(filename)
              except: 
                  tkMessageBox.showerror("Open Source File", "Failed to read file \n'%s'"%filename)
  </code></pre>
  
  <p>However I know Tkinter has a built in <code>askopenfilename</code> which is a super easy one line of code for opening files. Is there some way to modify this to return the directory instead of a file? Is there a smaller option than the larger chunk of code I posted?</p>