def get_file_name():
file_name = ""
# Button action function
def on_enter():
global file_name
file_name = entry.get()
return file_name
# Create main window
root = tk.Tk()
root.title("Tkinter Layout Example")
root.geometry("350x100")
# Create and place the label
label = ttk.Label(root, text="Enter your text:", font=("Arial, 16"))
label.pack(pady=(10, 5)) # Padding: 10px top, 5px bottom
# Create a frame for the entry and button
frame = ttk.Frame(root)
frame.pack(pady=5, padx=10, fill=tk.X)
# Create and place the entry field
entry = ttk.Entry(frame)
entry.pack(side=tk.LEFT, expand=True, fill=tk.X, padx=(0, 5)) # Expands to take available space
# Create and place the enter button
enter_button = ttk.Button(frame, text="Enter", command=on_enter)
enter_button.pack(side=tk.RIGHT)
# Run the application
root.mainloop()
I'm importing this function to a seperate file, and i want it to work such that when on_enter is called, the get_file_name will return the same as what on_enter returned