diff options
author | Jaime Resano <gemailpersonal02@gmail.com> | 2021-10-16 23:16:57 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-10-18 09:56:12 +0000 |
commit | deb23ae3f4edf011a94d3c09b0db51863889dd60 (patch) | |
tree | 7d642d167e0fa13eda8759e292bf2a3266bdd5c4 | |
parent | 3c1aba0f38ca5eb1023d659666c348fa8c2737ce (diff) |
Fix spelling take_at -> takeAt
Other minor improvements
Change-Id: I1a09b6ea813713f53c26f7244f2d913cc73c6c5b
Task-number: PYSIDE-841
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
(cherry picked from commit 2bcc7ceb19b4042ae3fe320c53e1c21fd765b16a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/widgets/layouts/flowlayout/flowlayout.py | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/examples/widgets/layouts/flowlayout/flowlayout.py b/examples/widgets/layouts/flowlayout/flowlayout.py index 431515687..f58dd7e96 100644 --- a/examples/widgets/layouts/flowlayout/flowlayout.py +++ b/examples/widgets/layouts/flowlayout/flowlayout.py @@ -1,4 +1,3 @@ - ############################################################################ ## ## Copyright (C) 2013 Riverbank Computing Limited. @@ -40,12 +39,11 @@ ## ############################################################################# -"""PySide6 port of the widgets/layouts/flowlayout example from Qt v5.x""" +"""PySide6 port of the widgets/layouts/flowlayout example from Qt v6.x""" import sys from PySide6.QtCore import Qt, QMargins, QPoint, QRect, QSize -from PySide6.QtWidgets import (QApplication, QLayout, QPushButton, - QSizePolicy, QWidget) +from PySide6.QtWidgets import QApplication, QLayout, QPushButton, QSizePolicy, QWidget class Window(QWidget): @@ -72,9 +70,9 @@ class FlowLayout(QLayout): self._item_list = [] def __del__(self): - item = self.take_at(0) + item = self.takeAt(0) while item: - item = self.take_at(0) + item = self.takeAt(0) def addItem(self, item): self._item_list.append(item) @@ -83,19 +81,19 @@ class FlowLayout(QLayout): return len(self._item_list) def itemAt(self, index): - if index >= 0 and index < len(self._item_list): + if 0 <= index < len(self._item_list): return self._item_list[index] return None def takeAt(self, index): - if index >= 0 and index < len(self._item_list): + if 0 <= index < len(self._item_list): return self._item_list.pop(index) return None def expandingDirections(self): - return Qt.Orientations(Qt.Orientation(0)) + return Qt.Orientation(0) def hasHeightForWidth(self): return True @@ -117,8 +115,7 @@ class FlowLayout(QLayout): for item in self._item_list: size = size.expandedTo(item.minimumSize()) - size += QSize(2 * self.contentsMargins().top(), - 2 * self.contentsMargins().top()) + size += QSize(2 * self.contentsMargins().top(), 2 * self.contentsMargins().top()) return size def _do_layout(self, rect, test_only): @@ -129,12 +126,12 @@ class FlowLayout(QLayout): for item in self._item_list: style = item.widget().style() - layout_spacing_x = style.layoutSpacing(QSizePolicy.PushButton, - QSizePolicy.PushButton, - Qt.Horizontal) - layout_spacing_y = style.layoutSpacing(QSizePolicy.PushButton, - QSizePolicy.PushButton, - Qt.Vertical) + layout_spacing_x = style.layoutSpacing( + QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Horizontal + ) + layout_spacing_y = style.layoutSpacing( + QSizePolicy.PushButton, QSizePolicy.PushButton, Qt.Vertical + ) space_x = spacing + layout_spacing_x space_y = spacing + layout_spacing_y next_x = x + item.sizeHint().width() + space_x @@ -153,7 +150,7 @@ class FlowLayout(QLayout): return y + line_height - rect.y() -if __name__ == '__main__': +if __name__ == "__main__": app = QApplication(sys.argv) main_win = Window() main_win.show() |