I need to create a large number of variables that take string input and that initially will be empty (pending user input).
Previously I've created the variables one at the time, eg
customer_id = StringVar()
customer_age = StringVar()
etc but this looks messy with a large number of variables.
I've looked at the answer in Issue with 'StringVar' in Python Program but I can't figure out how to use StringVar() with a for loop and a list.
I'm using Python 3.7.4, Windows 10.
# ATTEMPT
from tkinter import *
varlist = ['customer_id', 'customer_age', 'customer_phone']
for var in varlist:
Tk()
var = StringVar()
# ERROR MESSAGE WHEN CHECKING VARIABLES
type(customer_id)
NameError Traceback (most recent call last)
<ipython-input-24-9625f8af3cc2> in <module>
----> 1 type(customer_id)
NameError: name 'customer_id' is not defined
Thanks!
Tk()from the loop.