@kadin
To get the last value of a list of tkinter entry widgets, you can use the get()
method for each entry widget in the list and then access the last value in the list. Here's a sample code snippet that demonstrates this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import tkinter as tk root = tk.Tk() # Create a list of entry widgets entry_widgets = [] for i in range(5): entry = tk.Entry(root) entry.pack() entry_widgets.append(entry) # Function to get the last value of the list of entry widgets def get_last_value(): last_value = entry_widgets[-1].get() print("Last value:", last_value) # Button to trigger the function btn = tk.Button(root, text="Get Last Value", command=get_last_value) btn.pack() root.mainloop() |
In this example, we create a list of Entry widgets and store them in the entry_widgets
list. When the button is clicked, the get_last_value
function is called, which retrieves the last entry widget's value using entry_widgets[-1].get()
and prints it out.