Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing Entry widget information: tkinter python
    primarykey
    data
    text
    <p>I am writing a Tkinter program and have a root where a labels are displayed next to entry widgets.</p> <p>EX: Name -> SearchTerm ENTRY BOX</p> <p>I am trying to create a list of values from entry wigets (EX: ['', 'user input', 'user input'])</p> <p>I have created the entry widgets in the root and then have a function that gets the values:</p> <pre><code>def get_user_entries(user_entries): new_search_terms = [] for entry in user_entries: new_search_terms.append(entry.get()) return new_search_terms </code></pre> <p>I want to be able to access the list called new_search_terms in order to run another python program on it.</p> <p>I have tried to use the function as the command for a button. I have tried binding the button in different places. I have tried invoking the button in different places. I also tried creating a class where I new_search_terms was a class variable, but since I can't access the returned information from the function above the updated class variable did not hold. After exhausting the internet and several books I have yet to find an example where information is returned out of a Button function rather than printed. I need to be able to access this information in another place. </p> <p>Is there a way to access the information I need or is there another approach to this in Tkinter I haven't thought of?</p> <p>The code where I create the button:</p> <pre><code>done = Button(root, text='Done', command= lambda: get_user_entries(user_entries)) done.pack() </code></pre> <p>Here is the code that created the entries and labels:</p> <pre><code>def uc_1(original_names, final_names, root): user_entries = [] for index in range(len(original_names)): row = Frame(root) info = Label(row, text = original_names[index]+'-&gt;'+final_names[index]) user_entry = Entry(row) row.pack(side=TOP, fill=X) user_entry.pack(side=RIGHT, expand=YES, fill=X) user_entries.append(user_entry) info.pack(side=LEFT) return user_entries </code></pre> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload