Here is a solution using standard PyQt5 that I derived from shoosh's answer:
from PyQt5 import QtWidgets
class QHSeparationLine(QtWidgets.QFrame):
'''
a horizontal separation line\n
'''
def __init__(self):
super().__init__()
self.setMinimumWidth(1)
self.setFixedHeight(20)
self.setFrameShape(QtWidgets.QFrame.HLine)
self.setFrameShadow(QtWidgets.QFrame.Sunken)
self.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
return
class QVSeparationLine(QtWidgets.QFrame):
'''
a vertical separation line\n
'''
def __init__(self):
super().__init__()
self.setFixedWidth(20)
self.setMinimumHeight(1)
self.setFrameShape(QtWidgets.QFrame.VLine)
self.setFrameShadow(QtWidgets.QFrame.Sunken)
self.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred)
return
And if you want to add it (for example to a grid):
separator_vertical = separation_lines.QVSeparationLine()
separator_horizontal = separation_lines.QHSeparationLine()
grid = QtWidgets.QGridLayout()
grid.addWidget(your_widget_left_from_vertical_separator, 0, 0, 1, 1,)
grid.addWidget(separator_vertical, 0, 1, 1, 1)
grid.addWidget(your_widget_right_from_vertical_separator, 0, 2, 1, 1,)
grid.addWidget(separator_horizontal, 1, 0, 1, 2)
grid.addWidget(your_widget_below_horizontal_spacer, 2, 0, 1, 2)
Make sure to never use alignment on the separators, otherwise it will probably screw you over because they will not scale properly.
Just to show everything here is how to add it to your window:
import sys
if __name__ == "__main__":
app = QtWidgets.QApplication([])
widget = QtWidgets.QWidget()
widget.setLayout(grid)
widget.show()
sys.exit(app.exec())