The function need to be realized is: when the Tkinter button is clicked, an entry's text is changed. Here's the code snippet:
import Tkinter as tk
def create_heatmap_button_callback():
path_entry.delete(0, tk.END)
path_entry.insert(0, "clicked!")
def main():
root = tk.Tk()
path_entry = tk.Entry(master = root, text = "not clicked")
path_entry.grid(row=1, column=0, sticky = tk.W)
create_heatmap_button = tk.Button(master = root, text = "create map", command = create_heatmap_button_callback)
create_heatmap_button.grid(row=2,column=0,sticky = tk.W)
tk.mainloop()
if __name__ == "__main__":
global path_entry
main()
and when clicked the button, here's the output:
NameError: global name 'path_entry' is not defined
What is the correct way to do this?