[Tutor] Array of Tkinter objects?

Albert-Jan Roskam sjeik_appie at hotmail.com
Thu Sep 22 10:58:04 EDT 2016


Hi,

I have created a grid of Tkinter Entry object that looks a bit like a sheet in MS Excel. The data come from a pandas.DataFrame. I use a nested loop, one for rows and one for cols. Inside the loop, I create the Entry instances which I also grid() right away.

This works nicely, though a little slow. What data structure would be suitable so I can store the instances in it? I want to be able to easily call grid() on all of them. Also, I want to easily call .configure() on subsets, for instance to change the background color of a row when a certain value in that row is too high/low.

A numpy array of np.objects might be okay, but it is called NUMpy for a reason, no? Still, the way of indexing seems very useful/intuitive/neat here. Likewise for pd.DataFrame. Other options might be a list of lists, or a dictionary of the form {(row, col): Entry instance}.

Thanks in advance for your replies!

ALBERT-JAN


More information about the Tutor mailing list