I am writing a small program where there are two entry widgets that load the path from the configuration file.Is it possible to insert a value into each entry widget (values in the config are in order)?I only managed to insert values into one widget. And all the paths from the Input_311 config section are inserted there, but I only need one path in one widget. I plan on making a lot more Entry Widgets, I would like to optimize the insertion process.
CodePudding user response:
Since you have used tkinter variables in those Entry
widgets, I would suggest to create a list to store those tkinter variables, then use for loop to insert values into those Entry
widgets as below:
variables = [self.entry1Var1, self.entry2Var2, ...]
for var, path in zip(variables, CONFIG['Input_311'].values()):
var.set(path)
CodePudding user response:
With all advices, answer for my question is:
variables = [self.entry_1, self.entry_2]
for var, path in zip(variables, CONFIG['Input_311'].values()):
var.insert(0, path)