Created
December 10, 2015 14:05
-
-
Save JokerMartini/7fe4f204b6a7912be3ac to your computer and use it in GitHub Desktop.
Pyside + Python: Remove items from a layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clear_layout(self, layout): | |
while layout.count(): | |
child = layout.takeAt(0) | |
if child.widget() is not None: | |
child.widget().deleteLater() | |
elif child.layout() is not None: | |
clear_layout(child.layout()) | |
def clear_layout(self, layout): | |
for x in reversed(range(layout.count())): | |
widget = layout.takeAt(x).widget() | |
if widget is not None: | |
widget.deleteLater() | |
else: | |
clear_layout(layout.takeAt(x).layout()) | |
def clear_layout(self, layout): | |
for i in reversed(range(layout.count())): | |
layout.itemAt(i).widget().setParent(None) | |
def clear_layout(self, layout): | |
while layout.count(): | |
item = layout.takeAt(0) | |
widget = item.widget() | |
if widget is not None: | |
widget.deleteLater() | |
else: | |
clear_layout(item.layout()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment