I have a simple GUI in python. I want to print the value entered by the user from outside the function. The code I made is given below
def save_BasePath():
Base_Path_info = Base_Path.get()
#print(Base_Path_info)
file_basepath = open("basepath.txt", "w")
file_basepath.write(str(Base_Path_info))
file_basepath.close()
app = Tk()
app.geometry("500x500")
app.title("Python File Handling in Forms")
heading = Label(text="Input Print", fg="black", bg="yellow", width="500",
height="3", font="10")
heading.pack()
Base_Path_text = Label(text="Base_Path :")
Base_Path_text.place(x=155, y=70)
Base_Path = StringVar()
Base_Path_entry = Entry(textvariable=Base_Path, width="30")
Base_Path_entry.place(x=155, y=100)
button_basepath = Button(app, text="Enter Base Path", command=save_BasePath, width="15", height="2", bg="grey")
button_basepath.place(x=175, y=125)
#I need the user input from the function here so that I can use it further
mainloop()
On Pressing the button, I get the user input. I am able to print from within the save_basepath function. But I want to access the user input from outside so that I can work on it. Any help is appreciated
Base_Path.get()so what exactly is your problem?