![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
pyqt-checkbox-table-widget
Advanced tools
PyQt's QTableWidget which has checkbox as first header item
PyQt5 >= 5.8
python -m pip install pyqt-checkbox-table-widget
Many methods is changed/overriden because of the fact that check box being used in first column.
setHorizontalHeaderLabels(labels: typing.Iterable[str])
- Sets horizontal header label except for first column (for check box)
clearContents(start_r_idx=0)
- Remove all contents including check box from start_r_idx
setDefaultValueOfCheckBox(flag: bool)
- Self-explanatory.
stretchEveryColumnExceptForCheckBox()
- Apply self.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) except for first column, which is for check box.
setRowCount(rows: int)
toggleState(state)
- Toggle every single checkbox. State should be Qt.CheckState. You can see how to use this feature in Code Example 2 below.
getCheckedRows()
- Return the list of indexes of row which are checked.
getUncheckedRows()
setCheckedAt(idx: int, f: bool)
- If f is True, the check box at idx is checked. f is False, the check box at idx is unchecked.
removeCheckedRows()
removeUncheckedRows()
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
FAQs
PyQt's QTableWidget which has checkbox as first header item
We found that pyqt-checkbox-table-widget 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.