Hello I'm new to python and I'm stuck I need help.
My problem is this: I have a function that returns a string I call this function in a button How to get this value ?
My code :
from tkinter import*
from tkinter import filedialog
file_path = ''
def window():
fen=Tk() fen.geometry('{0}x{1}+{2}+{3}'.format(600, 400, 300, 200))
fen.config(bg = "#87CEEB")
return fen
def select_file():
file_path = filedialog.askopenfilename()
return file_path
def main():
fen = window()
bouton1 = Button(fen, text = "Select a file", command= select_file())
print(file_path)
fen.mainloop()
main()
If I print the file_path in my functions I can do it, it's perfect,
But I can't get it out of the function
windowfunction run?"