title: global variable not being assigned on tkinter python
body: <p>Im working on a project where I am trying to take a directory of a file. I am having issue assigning the directory to a global variable so that ...</p>
  
  <p>Here is my attempt:</p>
  
  <pre><code>dir = None
  def print_dir(event):
      print(dir)
  
  def main:
      root = Tk()
      def get_dir(event):
          ftypes = [('PDF',"*.pdf")]
          root.fileName = askopenfilename(filetypes = ftypes)
          dir = root.fileName
          return
       btn = Button(root,   text="+  Get dir")
       btn.grid(row=3, column=6)
       btn.bind("&lt;Button-1&gt;", get_dir)
  
       btn_two = Button(root,   text="+  Print dir")
       btn_two.grid(row=3, column=6)
       btn_two.bind("&lt;Button-1&gt;", print_dir)
  
       root.mainloop()
  </code></pre>
  
  <p>None is being printed even after opening the directory file using the first button.</p>