-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGridLayout_VBoxLayout.py
More file actions
44 lines (34 loc) · 1.32 KB
/
Copy pathGridLayout_VBoxLayout.py
File metadata and controls
44 lines (34 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
from PyQt5 import QtGui
from PyQt5.QtWidgets import QApplication, QMainWindow, QGridLayout, QDialog, QGroupBox, QPushButton, QVBoxLayout
class Window(QDialog):
def __init__(self):
super().__init__()
self.title = "PyQt5 Gridlayout"
self.top = 100
self.left = 100
self.width = 680
self.height = 500
self.initWindow()
def initWindow(self):
self.setWindowTitle(self.title)
self.setWindowIcon(QtGui.QIcon("Python-symbol.jpg"))
self.setGeometry(self.top, self.left, self.width, self.height)
self.gridLayoutCreate()
vboxLayout = QVBoxLayout()
vboxLayout.addWidget(self.groupBox)
self.setLayout(vboxLayout)
self.show()
def gridLayoutCreate(self):
self.groupBox = QGroupBox("Grid Layout Example")
gridLayout = QGridLayout()
gridLayout.addWidget(QPushButton('1'), 0, 0)
gridLayout.addWidget(QPushButton('2'), 0, 1)
gridLayout.addWidget(QPushButton('3'), 1, 0)
gridLayout.addWidget(QPushButton('4'), 1, 1)
gridLayout.addWidget(QPushButton('5'), 2, 0)
gridLayout.addWidget(QPushButton('6'), 2, 1)
self.groupBox.setLayout(gridLayout)
app = QApplication(sys.argv)
window = Window()
sys.exit(app.exec())