Skip to content

Instantly share code, notes, and snippets.

@KashEight
Created July 28, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KashEight/6478a9e53ad572bea75fecf74c5fb115 to your computer and use it in GitHub Desktop.
Save KashEight/6478a9e53ad572bea75fecf74c5fb115 to your computer and use it in GitHub Desktop.
import sys
from PySide2.QtWidgets import QWidget, QPushButton, QVBoxLayout, QHBoxLayout, QApplication
class MainWidget(QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
btn1 = QPushButton("button1")
child = ChildWidget(self)
main_layout = QVBoxLayout()
main_layout.addWidget(btn1)
main_layout.addWidget(child)
self.setLayout(main_layout)
class ChildWidget(QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
btn2 = QPushButton("button2")
grandson = GrandsonWidget(self)
child_layout = QHBoxLayout()
child_layout.addWidget(btn2)
child_layout.addWidget(grandson)
self.setLayout(child_layout)
class GrandsonWidget(QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
btn3 = QPushButton("button3")
btn4 = QPushButton("button4")
grandson_layout = QVBoxLayout()
grandson_layout.addWidget(btn3)
grandson_layout.addWidget(btn4)
self.setLayout(grandson_layout)
if __name__ == '__main__':
app = QApplication(sys.argv)
wdt = MainWidget()
wdt.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment