-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUISortList.py
31 lines (25 loc) · 1.06 KB
/
UISortList.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QRadioButton
import math
import utils
class UISortList(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent=parent)
layout = QVBoxLayout(self)
num_rows = 3
numItemsInColumn = math.floor(len(utils.valid_stats) / num_rows)
for row in range(num_rows):
nestLayout = QHBoxLayout()
for col in range(numItemsInColumn):
nestLayout.addWidget(QRadioButton(utils.valid_stats[row + col]))
layout.addLayout(nestLayout)
# Set first one as default
self.findChildren(QRadioButton)[0].setChecked(True)
# This goes through all the RadioButtons and finds which one is selected
# This is helpful when we figure out how to sort each line
def get_selected(self):
selected = ""
for radio in self.findChildren(QRadioButton):
if radio.isChecked():
selected = radio.text()
break # we found it so let's end for now
return selected