I'm trying to modify a global variable with my function, called "submit." The function is supposed to change the variables "start_stop_key" and "delay." I'm using "tkinter" as "tk" and the pynput library. My code is below:
# four variables are created to
# control the auto-clicker
# delay (in seconds)
delay = 0.001
# Button.right, Button.left, Button.middle for their respective mouse buttons
button = Button.right
start_stop_key = KeyCode(char=']')
stop_key = KeyCode(char='[')
def submit():
delay = delay_entry.get()
start_stop_key = start_stop_key_entry.get()
root = tk.Tk()
root.title("Buggie Autoclicker")
canvas = tk.Canvas(root, height=600, width=470)
canvas.pack()
delay_label = tk.Label(root, text="Time between clicks(in seconds):", font=("Arial", 14))
delay_label.pack(pady=20)
delay_entry = tk.Entry(root)
delay_entry.pack(pady=10)
start_stop_key_label = tk.Label(root, text="Key to toggle the autoclicker on and off:", font=("Arial", 14))
start_stop_key_label.pack(pady=20)
start_stop_key_entry = tk.Entry(root)
start_stop_key_entry.pack(pady=10)
submitbutton = tk.Button(root, text="Submit Values", command=submit())
submitbutton.pack(pady=20)
root.mainloop()