def layout_widgets(self, widgets): scroll_area = QtWidgets.QScrollArea() self.setWidget(scroll_area) grid = FlowLayout() grid_widget = QtWidgets.QWidget() grid_widget.setLayout(grid) for _, w in sorted(widgets, key=itemgetter(0)): grid.addWidget(w) scroll_area.setWidgetResizable(True) scroll_area.setWidget(grid_widget)
def layout_widgets(self, widgets): scroll_area = QtWidgets.QScrollArea() self.setWidget(scroll_area) grid = FlowLayout() grid_widget = QtWidgets.QWidget() grid_widget.setLayout(grid) for widget in sorted(widgets, key=lambda w: w.sort_key()): grid.addWidget(widget) scroll_area.setWidgetResizable(True) scroll_area.setWidget(grid_widget)