Last active
January 1, 2021 06:22
-
-
Save Park-Developer/bd9f1b76dc812c22a5a9cb844a78ca80 to your computer and use it in GitHub Desktop.
pyqt5 : setRowStretch(), setColumnStretch()
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
import random | |
import sys | |
from PyQt5 import QtGui, QtWidgets | |
if __name__ == "__main__": | |
app = QtWidgets.QApplication(sys.argv) | |
w = QtWidgets.QWidget() | |
glay = QtWidgets.QGridLayout(w) | |
for i in range(3): | |
for j in range(3): | |
label = QtWidgets.QLabel("{}x{}".format(i, j)) | |
color = QtGui.QColor(*random.sample(range(255), 3)) | |
label.setStyleSheet("background-color: {}".format(color.name())) | |
glay.addWidget(label, i, j) | |
glay.setRowStretch(0, 1) | |
glay.setRowStretch(1, 2) | |
glay.setRowStretch(2, 3) | |
w.resize(640, 480) | |
w.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/61451279/how-does-setcolumnstretch-and-setrowstretch-works