I'm trying to build this small window using Tkinter where people upload a link and it just returns it (the project is more complex but let's simplify).
This is the function that just prints the link string:
tag_list = []
def add_product_link(link):
global tag_list
product_tag = link[32:]
tag_list.append(product_tag)
print(tag_list)
Basically people put links in the text box and each time they press the "Add Link" button it adds a bit of the url in the tag_list list.
Here is my Tkinter code:
class StartPage(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text=('Enter the product links below !'), font=MEDIUM_FONT)
label.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
user_entry_text = tk.Label(self, text=('Link: '), font=MEDIUM_FONT)
user_entry_text.grid(row=1, column=0, sticky=tk.W, padx=10, pady=10)
user_entry = tk.Text(self, width=30, height=2)
user_entry.grid(row=1, column=1, sticky=tk.E, padx=10, pady=10)
#this button is problematic
quit_button = tk.Button(self, text=('Quit'), command=self.destroy)
quit_button.grid(row=2, column=1, sticky=tk.E, padx=10, pady=10)
url = user_entry.get()
add_button = tk.Button(self, text=('Add Item'), command=lambda: add_product_link(url))
add_button.grid(row=2, column=0, sticky=tk.W, padx=10, pady=10)
For some reason the user_entry.get() does not retrieve what I put in entry.
Thank you !