Попробуйте:
import sys
from PyQt5.QtCore import QPoint, Qt
from PyQt5.QtWidgets import (QApplication, QHBoxLayout, QLabel,
QPushButton, QVBoxLayout, QWidget)
from PyQt5.QtGui import QPixmap
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.layout = QVBoxLayout()
self.layout.addWidget(TopContentBlock(self))
self.layout.addWidget(BottomContentBlock(self))
self.setLayout(self.layout)
self.layout.setContentsMargins(0,0,0,0)
self.layout.setSpacing(0)
# self.layout.addStretch(1)
self.setMinimumSize(640,600) # 600
self.setWindowFlags(Qt.FramelessWindowHint)
#? self.pressing = False
class TopContentBlock(QWidget):
def __init__(self, parent):
super(TopContentBlock, self).__init__();
#? self.parent = parent;
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.content = QWidget()
self.content.setFixedSize(640, 200) #(640, 250)
self.content.setStyleSheet("""
background-color: #67BEC3;
""")
self.img = QLabel()
self.img.setAlignment(Qt.AlignCenter) # +++
pixmap = QPixmap('im.png') #('main_illustration.png')
# self.img.setPixmap(pixmap)
self.img.setPixmap(pixmap.scaled(200, 200, # +++
Qt.IgnoreAspectRatio,
Qt.FastTransformation))
# self.img.resize(pixmap.width(), pixmap.height())
#self.img.setFixedSize(pixmap.width(), pixmap.height())
self.layout.addWidget(self.img)
self.layout.addWidget(self.content)
self.layout.setSpacing(0) # +++
self.setLayout(self.layout)
class BottomContentBlock(QWidget):
def __init__(self, parent):
super(BottomContentBlock, self).__init__();
self.parent = parent;
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.content = QWidget()
self.content.setFixedSize(640, 200) #(640, 400)
self.content.setStyleSheet("""
background-color: cyan;
""")
self.layout.addWidget(self.content)
self.setLayout(self.layout)
if __name__ == "__main__":
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())
![enter image description here](https://i.stack.imgur.com/OWCSC.png)
Обновление
import sys
from PyQt5.QtCore import QPoint, Qt
from PyQt5.QtWidgets import (QApplication, QHBoxLayout, QLabel,
QPushButton, QVBoxLayout, QWidget)
from PyQt5.QtGui import QPixmap
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.layout = QVBoxLayout()
self.layout.addWidget(TopContentBlock(self))
self.layout.addWidget(BottomContentBlock(self))
self.setLayout(self.layout)
self.layout.setContentsMargins(0,0,0,0)
self.layout.setSpacing(0)
# self.layout.addStretch(1)
self.setMinimumSize(640,400) # 400
self.setWindowFlags(Qt.FramelessWindowHint)
#? self.pressing = False
class TopContentBlock(QWidget):
def __init__(self, parent):
super(TopContentBlock, self).__init__();
#? self.parent = parent;
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
# self.content = QWidget() # --- <---
self.setFixedSize(640, 200) # --- .content
self.setStyleSheet("""
background-color: #67BEC3;
""") # --- .content
self.img = QLabel()
self.img.setAlignment(Qt.AlignCenter) # +++
pixmap = QPixmap('im.png') #('main_illustration.png')
# self.img.setPixmap(pixmap)
self.img.setPixmap(pixmap.scaled(200, 200, # +++
Qt.IgnoreAspectRatio,
Qt.FastTransformation))
# self.img.resize(pixmap.width(), pixmap.height())
#self.img.setFixedSize(pixmap.width(), pixmap.height())
self.layout.addWidget(self.img)
# self.layout.addWidget(self.content) # ---
self.layout.setSpacing(0) # +++
self.setLayout(self.layout)
class BottomContentBlock(QWidget):
def __init__(self, parent):
super(BottomContentBlock, self).__init__();
self.parent = parent;
self.layout = QVBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.content = QWidget()
self.content.setFixedSize(640, 200) #(640, 400)
self.content.setStyleSheet("""
background-color: cyan;
""")
self.layout.addWidget(self.content)
self.setLayout(self.layout)
if __name__ == "__main__":
app = QApplication(sys.argv)
mw = MainWindow()
mw.show()
sys.exit(app.exec_())
![enter image description here](https://i.stack.imgur.com/rj9ah.png)