Python ObjectListView -- how to split a list into two columns

219 views Asked by At

I have an ObjectListView in wxPython that I would like to split into two identical lists that sit next to each other instead of one long list with a scrollbar. So, instead of:

Column 1 -- Column 2 -- Column 3
data        data        data
data        data        data

I would like it to look like this:

Column 1 -- Column 2 -- Column 3     Column 1 -- Column 2 -- Column 3
data        data        data         data        data        data

Of course, with more data split evenly between them, if possible. Is there a way to accomplish this without making two separate lists? The reason I don't want to make two lists is that I have one large object list I'd like to pass it and with two lists I think I'd have to split the object in two and send a section to each list; if elegance is an option, I'd prefer it.

1

There are 1 answers

3
Rolf of Saxony On

If you use list_B = list_A you are not making "another" list, instead you are simply saying that there are 2 names for the same list, they both point to the same thing. You can use id() to check that this is true.

>>> list_A = [1,2,3,4,5,6,7,8]
>>> id(list_A)
140229575676488
>>> list_B = list_A
>>> id(list_B)
140229575676488
>>> list_A
[1, 2, 3, 4, 5, 6, 7, 8]
>>> list_B
[1, 2, 3, 4, 5, 6, 7, 8]
>>> list_A.append(9)
>>> list_A.append(10)
>>> list_A
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> list_B
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]