Package: pyqt5-tile-layout
qt-tile-layoutA tile layout for PyQt where you can put any widget in a tile. The user is then able to drag and drop the tiles and resize themQuick exampleJust launch thetest.pyscript to have a first look (be sure to have installed PyQt5 from therequirements.txtfile).
You can have an overview of how to use the different methods in this script.Moreover, you can change the value ofstatic_layoutvariable toFalseto experiment a tile layout where the tile sizes are dynamics with the parent widget size (like a classic layout)If you are interested about drag and drop widgets between several QTileLayouts, check thetestLink.pyscript.Create and use a tile layoutFirst, you have to install the PyPi package:pipinstallpyqt5-tile-layoutAnd import the QTileLayout:fromQTileLayoutimportQTileLayoutThen, let's create a tile layout with 8 rows and 5 columns.We also give the vertical and horizontal spawn in pixel:layout=QTileLayout(rowNumber=8,columnNumber=5,verticalSpawn=100,horizontalSpan=150,verticalSpacing=5,horizontalSpacing=5,)We can now add a widget in a specific position: it's the same as the grid layout:layout.addWidget(widget=QtWidgets.QLabel('Hello world'),fromRow=3,fromColumn=2,rowSpan=1,columnSpan=2,)Finally, if you put your layout into a window, you will be able to drag and drop the above widget and resize itsDocumentationQTileLayout(int fromRow, int fromColumn, int rowSpan, int columnSpan, int verticalSpacing, int horizontalSpacing)Constructs a new tile layoutMethods:acceptDragAndDrop(bool value)Allows or not the drag and drop of tiles in the layoutacceptResizing(bool value)Allows or not the resizing of tiles in the layoutactivateFocus(bool focus)Activates or not the widget focus after drag & drop or resize. This feature can lead to unexpected behaviours in some cases, please set focus on false if you notice any of themaddcolumns(int columnNumber)Adds columns at the right of the layoutaddRows(int rowNumber)Adds rows at the bottom of the layoutaddWidget(QWidget widget, int fromRow, int fromColumn, int rowSpan, int columnSpan)Adds the given widget to the layout, spanning multiple rows/columns. The tile will start at fromRow, fromColumn spanning rowSpan rows and columnSpan columnscolumnCount() -> intReturns the number of column in the layoutcolumnsMinimumwidth() -> intReturns the minimal tile width of span onegetId() -> strReturns the layout idhorizontalSpacing() -> intReturns the horizontal spacing between two tileslinkLayout(QTileLayout layout)Allows the drag and drop between several layouts (see testLink.py)removecolumns(int columnNumber)Removes columns at the right of the layout, raises an error if a widget is in the target arearemoveRows(int rowNumber)Adds rows at the bottom of the layout, raises an error if a widget is in the target arearemoveWidget(QWidget widget)Removes the given widget from the layoutrowCount() -> intReturns the number of row in the layoutrowsMinimumHeight() -> intReturns the minimal tile height of span onesetColorDragAndDrop(tuple color)Sets the RGB color of the tiles during drag and dropsetColorIdle(tuple color)Sets the default RGB color of the tilessetColorResize(tuple color)Sets the RGB color of the tiles during resizingsetColorEmptyCheck(tuple color)Sets the RGB color of the tiles where the dragged tile fits during drag and dropsetColumnsWidth(int width)Sets the tiles width (in pixels) of span onesetColumnsMinimumWidth(int width)Sets the minimum tiles width (in pixels) of span onesetCursorGrab(QtCore.Qt.CursorShape value)Changes the cursor shape when it is possible to drag a tilesetCursorIdle(QtCore.Qt.CursorShape value)Changes the cursor shape when it is over a tilesetCursorResizeHorizontal(QtCore.Qt.CursorShape value)Changes the cursor shape when it is possible to resize a tile horizontallysetCursorResizeVertical(QtCore.Qt.CursorShape value)Changes the cursor shape when it is possible to resize a tile verticallysetHorizontalSpacing(int spacing)Changes the horizontal spacing between two tilessetRowsHeight(int height)Sets the tiles height (in pixels) of span onesetRowsMinimumHeight(int height)Sets the minimum tiles height (in pixels) of span onesetVerticalSpacing(int spacing)Changes the vertical spacing between two tilestileRect(int row, int column) -> QRectReturns the geometry of the tile at (row, column)unLinkLayout(QTileLayout layout)Forbids the drag and drop between several layouts (see testLink.py)verticalSpacing() -> intReturns the vertical spacing between two tileswidgetList() -> listReturns the widgets that are currently in the layoutSignals:tileMoved(QWidget widget, str fromLayoutId, str toLayoutId, int fromRow, int fromColumn, int toRow, int toColumn)Emits when a tile is moved successfully. When the source layout is not the same than the destination one, the signal is emitted from the destination layouttileResized(QWidget widget, int fromRow, int fromColumn, int rowSpan, int columnSpan)Emits when a tile is resized successfullyLast wordFeel free to use this layout and to notice me if there are some bugs or useful features to add