Make working with QGridLayout easier
Project description
qtgrid
The python qtgrid package is for PyQt, or PySide developers. It helps to build QGridLayout's dynamically and with visual help during implementation time. Note that qtgrid works in the same way for PyQt5, PyQt6, and PySide6.
See also the tutorial, the reference manual, or for the brave the API Documentation.
This package is licensed under GNU LGPLv3.
Example Usage
from qtgrid import Grid
grid = Grid(
layout = QGridLayout(), # QGridLayout object (eg. from QtDesigner)
content_columns = 8, # Maximum number of columns
expand_left = False, # Apply left side expander
expand_right = True, # Apply right side expander
column_gaps = [
# Define gap's for complete columns
(0, 0), # (column_index, width) / width can be ...
(2, 20), # - 0 or None := set cells explicitly empty (as is)
(4, "expand"), # - "expand" := add horizontal expander
(6, 20), # - number := add horizontal spacer of fixed size
],
# Prepare your own lists, to access your added widgets afterwards.
# See also layout.add(), and layout.add_label().
list_names = ["headers", "labels"],
# Show visual help while development
work_up = True
)
# QGridLayout settings
grid.layout.setSpacing(1)
Add arbitrary widgets to the grid layout. Don't bother about indices.
myLabel = QLabel("add example")
grid.add(
widget = myLabel, # required
y_span = 1, # optional
x_span = 1, # optional
to_list = "labels" # optional / add the widget to your prepared list named "labels"
)
# .. or simply ..
grid.add( myLabel )
qtgrid is mostly about widgets layout. But especially for labels you can use appropriate configured ones as a blueprint for a common design :
# Add a label as a copy source
myLabel = QLabel()
# ... configure your label ...
grid.set_label_source( name_id="foo", label=myLabel )
# Add a new label to the grid and copy its config from "foo"
grid.add_label("foo", "Some Text")
grid.add_label("foo", "Some Text", to_list="labels")
Gaps within the grid are quite essential :
# Add horizontal gaps
grid.add_gap(20) # add fixed size spacer
grid.add_gap("expander") # add expanding spacer
# Add vertical gaps
grid.add_gap("V", 20)
grid.add_gap("V", "expander")
# Add empty row below the current row
grid.add_empty_row(20)
grid.add_empty_row("expand")
Always call the following method at the end. This will actually apply all widgets, gaps, and expander to the underlying QGridLayout object.
grid.finish()
Later on, to access your prepared lists:
headers = grid.get_list("headers")
labels = grid.get_list("labels")
for i in range( len(headers) ):
print( headers[i].text() )
print( labels[i].text() )
Install
Use pip or pipenv
- pip install qtgrid
- pipenv install qtgrid
Get the current project source from GitHub
- git clone https://github.com/devlog42/qtgrid
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file qtgrid-1.0.0b0.tar.gz
.
File metadata
- Download URL: qtgrid-1.0.0b0.tar.gz
- Upload date:
- Size: 22.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 134126c86ca02998a9da79bdf96d18231a67b6b6bde46847310a2635e7942d51 |
|
MD5 | d09afbc00cf508ca22a84c3ea9ebf333 |
|
BLAKE2b-256 | d79cffa72d6b48b925753e6122b18eead8676cd8d72830150ccb05ce13384bef |
File details
Details for the file qtgrid-1.0.0b0-py3-none-any.whl
.
File metadata
- Download URL: qtgrid-1.0.0b0-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c88f5497893fbaf9ec8e97a8f8a0b9b10fe1054318a2034aa6d59cedac1526ac |
|
MD5 | 6f140c02790b4f4b56b6eba5920f5816 |
|
BLAKE2b-256 | 89d6df021f99ca71e4592a051106f644a23b056fcd68c0de9a14e2a2148c894d |