title: Python: Use of variables (filename) from one function to another in Tkinter application
body: <p>I am trying to use user input (filename) into another function however getting error when using, even though I have declared it as global variable as highlighted. Any feedback is much appreciated.
  #############################################################################################</p>
  <pre><code>####Function I####
  
  # upload action function
  def UploadAction(event=None):
      global filename
      path = filedialog.askopenfilename()
      statuslabel = Label(frame1, bd=1, padx=5,relief='ridge', justify=LEFT,bg=&quot;spring green&quot;)
      statuslabel.configure(text=&quot;File opened sucessfully:\n&quot; +path)
      statuslabel.pack()
      statuslabel.place(x=590, y=375, anchor='ne')
      filename =ntpath.basename(&quot;{}&quot;.format(path))
  
  button = Button(frame1,text = &quot;Upload IOS&quot;, command =UploadAction)
  button.pack()
  button.place(x=300, y=370, anchor='ne')
  
  print(filename)  ## issue here as cant print 
  
  ####Function II#####
  
  def md5Verify():
      command = &quot;verify /md5&quot; &quot;flash:&quot;&quot;{}&quot;.format(filename) 
      output = connection.send_command_timing(command, strip_prompt=False, strip_command=False, 
      delay_factor=5)
      #print(output)
      output = re.search(' = (\w+)', str(output))
      #print(output.group(1))
      md5_entry1 = &quot;{}&quot;.format(md5_entry.get())
      print(md5_entry1)
      print(&quot;hello&quot;)
      if md5_entry1 == str(output.group(1)):
        print(&quot;MD5 checksum verified&quot;)
      elif md5_entry1 != str(output.group(1)):
        print(&quot;MD5 Hash mish match&quot;)
  ## issue here as cant use the variable in this function.
        
  </code></pre>