Feb-05-2021, 01:30 PM
Hi all,
I am using the below code (PART A) to allow a user to enter words.
Then, I want to save what a user entered into a normal list. Indeed, I need this data as a list for the rest of the project (PART B). You can see in red that, for now, I tried to use the listbox directly, but of course it doesn't work.
How can I save what users are entering into list?
Thanks,
------------------------------PART A
I am using the below code (PART A) to allow a user to enter words.
Then, I want to save what a user entered into a normal list. Indeed, I need this data as a list for the rest of the project (PART B). You can see in red that, for now, I tried to use the listbox directly, but of course it doesn't work.
How can I save what users are entering into list?
Thanks,
------------------------------PART A
root = tk.Tk() root.title("Ticker List") root.geometry("400x400") def clicked(): listbox.insert(tk.END, content.get()) def delete(): listbox.delete(0, tk.END) def delete_selected(): listbox.delete(tk.ANCHOR) # LISTBOX content = tk.StringVar() entry = tk.Entry(root, textvariable=content) entry.pack() button = tk.Button(root, text="Add Ticker", command=clicked) button.pack() button_delete = tk.Button(text="Delete All", command=delete) button_delete.pack() button_delete_selected = tk.Button(text="Delete Selected Ticker", command=delete_selected) button_delete_selected.pack() listbox = tk.Listbox(root) listbox.pack() root.mainloop()------------------------------------PART B
start = datetime(2020,1,1) end = datetime(2020,7,31) stock = [b][color=#C0392B]listbox[/color][/b][u][/u] df = web.DataReader(stock,'yahoo',start,end) df.to_excel(f'stockdata_{stock}.xlsx')