Python Forum
Print Values from a Sequence of Entries / ComboBoxes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print Values from a Sequence of Entries / ComboBoxes
#2
For starters, to get the value of a Combobox you either use Combobox.get(), or you assign the Combobox a String_Var and use String_Var.get().

Even if you used the correct command to get the Combobox value you don't have any way to get hold of the combo boxes. You could do what you tried to do with the Entry widgets (more about that in a moment), creating a String_Var for each one, putting the String_Var's in a list and using them to get the value, or you could just keep the Combobox objects in a list. What you cannot do is use a local variable and throw it away leaving no way to access the Combobox widget or value.

The Entry widgets don't work either, and that is because you are not binding the entry_values to the Entry widgets. You need to do something like this:
string_var = tk.StringVar()
entry_values.append(string_var)
e2 = Entry(root, textvariable=string_var)  #<- Need this for it to work
You are missing a lot of bookkeeping that needs to be done to convert this into a viable program. If you want to grow the list of players each time using the Add button you'll have to keep track of the player name Entry widgets and position combo boxes so they can be hidden (pack_forget) when you want to start a new lineup. You may find it easier to create all the widgets you will ever need, and provide a way to identify which widgets contain players. Perhaps checking for a non-empty string in the player name Entry.
Reply


Messages In This Thread
RE: Print Values from a Sequence of Entries / ComboBoxes - by deanhystad - Mar-26-2020, 05:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't get tkinter database aware cascading comboboxes to update properly dford 6 3,939 Jan-11-2022, 08:37 PM
Last Post: deanhystad
  Linking Comboboxes MrP 24 7,808 Feb-03-2021, 10:59 PM
Last Post: MrP
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 6,274 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  [PyQt] making dependant comboBoxes Hitsugaya 3 5,214 May-23-2019, 06:05 PM
Last Post: Alfalfa

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020