I ask you a question when setting the coordinate value during the layer-out setting.

Asked 2 years ago, Updated 2 years ago, 89 views

Grid layout is creating values and lists

[     1     ][     2    ][     3    ][     4    ]
[     5     ][     6    ][     7    ][     8    ]

Like the one above, I'm making 4 x 2 slots i and j were made as coordinate values, but I want to put 8 widget values in the list value, but I don't know what it is I don't know if I should do it this way.

a = [1,2,3,4,5,6,7,8]
b = 0
for i in range(2):
    for j in range(4):
        grid1.addWidget(a[b], i, j)
        b += 1

I made it this way, but what's a more accurate way?

pyqt python

2022-09-21 14:33

1 Answers

Are you asking me this?

a = [1,2,3,4,5,6,7,8]

for i in range(2):
    for j in range(4):
        grid1.addWidget(a[i*4+j], i, j)


2022-09-21 14:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.