PyQt's QTableWidget which has checkbox as first header item
Project description
pyqt-checkbox-table-widget
PyQt's QTableWidget which has checkbox as first header item
Requirements
PyQt5 >= 5.8
Setup
python -m pip install pyqt-checkbox-table-widget
Example
Code Example 1
from PyQt5.QtWidgets import QApplication, QTableWidgetItem
from pyqt_checkbox_table_widget.checkBoxTableWidget import CheckBoxTableWidget
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
widget = CheckBoxTableWidget()
widget.setRowCount(3)
widget.setItem(0, 1, QTableWidgetItem('abc')) # Remember column argument should be at least 1 (if it is zero, item will cover the checkbox cell)
widget.show()
app.exec_()
Result
Code Example 2
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QTableWidgetItem, QMainWindow, QCheckBox, QVBoxLayout, QWidget
from pyqt_checkbox_table_widget.checkBoxTableWidget import CheckBoxTableWidget
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
allChkBox = QCheckBox('Check all')
tableWidget = CheckBoxTableWidget()
tableWidget.setRowCount(10)
tableWidget.stretchEveryColumnExceptForCheckBox() # stretch every section of tablewidget except for check box section
for i in range(tableWidget.rowCount()):
item = QTableWidgetItem()
item.setTextAlignment(Qt.AlignCenter) # align
item.setText(str(i)*50) # text sample
tableWidget.setItem(i, 1, item)
allChkBox.stateChanged.connect(tableWidget.toggleState) # if allChkBox is checked, tablewidget checkboxes will also be checked
lay = QVBoxLayout()
lay.addWidget(allChkBox)
lay.addWidget(tableWidget)
mainWidget = QWidget()
mainWidget.setLayout(lay)
self.setCentralWidget(mainWidget)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
Result
Similar package
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
Close
Hashes for pyqt-checkbox-table-widget-0.0.11.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | edfa1f8715a866f46626ab7b295e696a2c13afe1cc25a47463799cf6f0cb9120 |
|
MD5 | baf634340226d72f517b80585cf07e75 |
|
BLAKE2b-256 | d66c028dc99831009cc5808d9be3232679de647565d74ce39b563e3fae543288 |
Close
Hashes for pyqt_checkbox_table_widget-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 520b4a1f58a843c55f6b72c8180523ad50c2dc381c18ff1a558d321b19839b30 |
|
MD5 | ee24cffc934fddb1e2f87b06f263cba5 |
|
BLAKE2b-256 | 5c5d55617147944179355c4735bc6680f6efad030c2ad9bacc97cfee2b4d36b4 |