Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
A 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 them
Just launch the test.py
script to have a first look (be sure to have installed PyQt5 from the requirements.txt
file).
You can have an overview of how to use the different methods in this script.
Moreover, you can change the value of static_layout
variable to False
to 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 the testLink.py
script.
First, you have to install the PyPi package:
pip install pyqt5-tile-layout
And import the QTileLayout:
from QTileLayout import QTileLayout
Then, 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 its
QTileLayout(int fromRow, int fromColumn, int rowSpan, int columnSpan, int verticalSpacing, int horizontalSpacing)
Constructs a new tile layout
acceptDragAndDrop(bool value)
Allows or not the drag and drop of tiles in the layout
acceptResizing(bool value)
Allows or not the resizing of tiles in the layout
activateFocus(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 them
addcolumns(int columnNumber)
Adds columns at the right of the layout
addRows(int rowNumber)
Adds rows at the bottom of the layout
addWidget(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 columns
columnCount() -> int
Returns the number of column in the layout
columnsMinimumwidth() -> int
Returns the minimal tile width of span one
getId() -> str
Returns the layout id
horizontalSpacing() -> int
Returns the horizontal spacing between two tiles
linkLayout(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 area
removeRows(int rowNumber)
Adds rows at the bottom of the layout, raises an error if a widget is in the target area
removeWidget(QWidget widget)
Removes the given widget from the layout
rowCount() -> int
Returns the number of row in the layout
rowsMinimumHeight() -> int
Returns the minimal tile height of span one
setColorDragAndDrop(tuple color)
Sets the RGB color of the tiles during drag and drop
setColorIdle(tuple color)
Sets the default RGB color of the tiles
setColorResize(tuple color)
Sets the RGB color of the tiles during resizing
setColorEmptyCheck(tuple color)
Sets the RGB color of the tiles where the dragged tile fits during drag and drop
setColumnsWidth(int width)
Sets the tiles width (in pixels) of span one
setColumnsMinimumWidth(int width)
Sets the minimum tiles width (in pixels) of span one
setCursorGrab(QtCore.Qt.CursorShape value)
Changes the cursor shape when it is possible to drag a tile
setCursorIdle(QtCore.Qt.CursorShape value)
Changes the cursor shape when it is over a tile
setCursorResizeHorizontal(QtCore.Qt.CursorShape value)
Changes the cursor shape when it is possible to resize a tile horizontally
setCursorResizeVertical(QtCore.Qt.CursorShape value)
Changes the cursor shape when it is possible to resize a tile vertically
setHorizontalSpacing(int spacing)
Changes the horizontal spacing between two tiles
setRowsHeight(int height)
Sets the tiles height (in pixels) of span one
setRowsMinimumHeight(int height)
Sets the minimum tiles height (in pixels) of span one
setVerticalSpacing(int spacing)
Changes the vertical spacing between two tiles
tileRect(int row, int column) -> QRect
Returns the geometry of the tile at (row, column)
unLinkLayout(QTileLayout layout)
Forbids the drag and drop between several layouts (see testLink.py)
verticalSpacing() -> int
Returns the vertical spacing between two tiles
widgetList() -> list
Returns the widgets that are currently in the layout
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 layout
tileResized(QWidget widget, int fromRow, int fromColumn, int rowSpan, int columnSpan)
Emits when a tile is resized successfully
Feel free to use this layout and to notice me if there are some bugs or useful features to add
FAQs
A tile layout for PyQt5
We found that pyqt5-tile-layout demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.