I have different lists, and for each list, I'd like to display its items in a column. I want one list per column.
Basically, I can already achieve that result by manually changing the column variable col1
, col2
, etc. but the problem is that the number of lists may vary.
catalogs_list = ["TRANSFORMS", "DEFORMS", "CONFORMS", "HELPERS", "MASKS"]
list1 = ["transforms 1", "transforms 2", "transforms 3", "transforms 4"]
list2 = ["deforms 1", "deforms 2", "deforms 3"]
list3 = ["conforms 1", "conforms 2"]
list4 = ["helpers 1", "helpers 2", "helpers 3"]
list5 = ["masks 1", "masks 2"]
master_list = [list1, list2, list3, list4, list5]
top_row = layout.row(align=False)
for item in catalogs_list:
top_row.label(text=item)
split = layout.split()
col1 = split.column()
for item in master_list[0]:
col1.label(text=item)
col2 = split.column()
for item in master_list[1]:
col2.label(text=item)
col3 = split.column()
for item in master_list[2]:
col3.label(text=item)
col4 = split.column()
for item in master_list[3]:
col4.label(text=item)
col5 = split.column()
for item in master_list[4]:
col5.label(text=item)
The code above gets me this, which is exactly what I want:
But I want to achieve the same thing as the image above but in a 'for loop' because I need as many columns as my number of lists (which is unknown in advance):
number_of_columns = len(catalogs_list)
split = layout.split()
col = split.column()
for i in range(number_of_columns):
for item in master_list[i]:
col.label(text=item)
This is what I get with the code above, and I lose the columns. And I can't increment the variable name col
(like when I knew the number of columns in advance):
So how can I achieve this?
Thanks.