I'm setting up a makeshift tkinter window client that looks like this:
His further information can be accessed by a secondary window like this:
When I try updating his address by just clicking update, it ends up looking like this:
So I know for a fact that the back end database is not the problem, since I can update the address and what not without any issues just calling the update function from the backend.py script. However, from the front end, when I use a print statement, I found that the entry_value.get() is an empty string whenever I enter the new window.
So I tried globalizing the variable, I tried maybe putting the variable out of the functions and in the main loop instead. I was thinking of using OOP approach, but I believe I shouldn't have to completely break apart my code and change it to OOP just so that entry_value.get() isn't empty.
I've also looked for answers about this matter, but I can't seem to find this particular problem anywhere.
Here's the problem area in my code:
def open_menu():
global new_window
new_window = Tk()
address_entry_value = StringVar()
address_entry = Entry(new_window, width = 50, textvariable = address_entry_value)
address_entry.grid(row = 1, column = 1, columnspan = 3)
address_entry.delete(0, END)
address_entry.insert(END, "Insert Address Here")
print(address_entry_value.get())
def get_selected_row(event):
try:
global selected_tuple
global extended_tuple
index = listbox.curselection()[0]
selected_tuple = listbox.get(index)
selected_tuple = selected_tuple.split()
extended_tuple = backend.select_client(selected_tuple[0])
except IndexError:
pass
def open_clients_entry(event):
open_menu()
window = Tk()
listbox = Listbox(window, width = 75, height = 10)
listbox.grid(row = 1, column = 0, columnspan = 4, rowspan = 7)
listbox.bind("<Double-Button-1>", open_clients_entry)
listbox.bind("<<ListboxSelect>>", get_selected_row)
open_entry_button = Button(window, width = 12, text = "Open Entry", command = open_menu)
open_entry_button.grid(row = 4, column = 5)
window.mainloop()
I'm using "Insert Address Here" for the purpose of using an example instead of using tuples and what not from the database for simplicity in getting to the point of the problem here.
The expected print result in the powershell window should be "Insert Address Here", instead it prints a blank. Hence when I update the address also becomes blank as it takes in an empty address_entry_value.get() like in the pictures below.
This leads to
Any help would be greatly appreciated as I'm really stumped on this problem.