I am trying to get a value from a closure in an other module. When I press the button in the GUI the file dialog creates a string with the path of the file (so this step works). The string should then be accessible in the main.py. This step doesn't work, in the main it's always None.
This is what I have in file main.py:
import mat_import
import GUI
filename1 = GUI.gui()
print(filename1)
This is what I have in the GUI.py
from tkinter import *
from tkinter import filedialog
from PIL import ImageTk, Image
import os
import math
import sys
def gui():
    mainpage = Tk()   
    def choose_file1():
        filename1 = filedialog.askopenfilename()
        lbl_read_file1_path = Label()
        lbl_read_file1_path.configure(text = filename1)
        lbl_read_file1_path.grid(column=1, row=5, sticky="W", columnspan=3)
        return filename1
    def returnfile1():
        return choose_file1()
    button_read_file1 = Button(mainpage, text="Durchsuchen...", command = returnfile1)
    button_read_file1.config(height = 1, width = 15)
    button_read_file1.grid(column=0, row=5, sticky="W")
    mainloop()
What do I have to change to "print" the string with the filename from function choose_file1 (defined inside the function gui) in file main.py?
 
    