PyQt QListWidget for files and supporting the checkbox
Project description
pyqt-checkbox-file-list-widget
PyQt QListWidget for files and supporting the checkbox.
The main class CheckBoxFileListWidget
inherits from both FileListWidget
(pyqt-file-list-widget) and CheckBoxListWidget
(pyqt-checkbox-list-widget).
Requirements
PyQt5 >= 5.8
Included Packages
-
pyqt-file-list-widget - Parent class
-
pyqt-checkbox-list-widget - Parent class
Feature
getCheckedFilenames() -> list
Setup
python -m pip install pyqt-checkbox-file-list-widget
Code Example
import os
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMainWindow, QCheckBox, QHBoxLayout, \
QVBoxLayout, QWidget, QApplication, QPushButton
from pyqt_checkbox_file_list_widget import CheckBoxFileListWidget
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
allChkBox = QCheckBox('Check all')
showFilesNameOnlyChkBox = QCheckBox('Show files name only')
self.__listWidget = CheckBoxFileListWidget()
self.__listWidget.setDatas([os.path.join(os.getcwd(), filename) for filename in os.listdir(os.getcwd())])
allChkBox.stateChanged.connect(self.__listWidget.toggleState)
showFilesNameOnlyChkBox.stateChanged.connect(self.__listWidget.setFilenameOnly)
lay = QHBoxLayout()
lay.setAlignment(Qt.AlignLeft)
lay.addWidget(allChkBox)
lay.addWidget(showFilesNameOnlyChkBox)
lay.setContentsMargins(0, 0, 0, 0)
topLeftWidget = QWidget()
topLeftWidget.setLayout(lay)
self.__deleteBtn = QPushButton('Delete')
self.__deleteBtn.clicked.connect(self.__delete)
lay = QHBoxLayout()
lay.setAlignment(Qt.AlignRight)
lay.addWidget(self.__deleteBtn)
lay.setContentsMargins(0, 0, 0, 0)
topRightWidget = QWidget()
topRightWidget.setLayout(lay)
lay = QHBoxLayout()
lay.addWidget(topLeftWidget)
lay.addWidget(topRightWidget)
lay.setContentsMargins(0, 0, 0, 0)
topWidget = QWidget()
topWidget.setLayout(lay)
lay = QVBoxLayout()
lay.addWidget(topWidget)
lay.addWidget(self.__listWidget)
mainWidget = QWidget()
mainWidget.setLayout(lay)
self.setCentralWidget(mainWidget)
def __delete(self):
self.__listWidget.removeCheckedRows()
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
htmlViewer = MainWindow()
htmlViewer.show()
app.exec_()
Result
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-file-list-widget-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66ea2bc32f63acd1ff19995bd9eb08759dec8cb8651d5dd8317455527e390bc3 |
|
MD5 | 46362ce7a5dbd145c68499b77f75abe9 |
|
BLAKE2b-256 | cf049b882b63e3f4265017296e04bf5b85e0b46240414069d4e5038c76f1c747 |
Close
Hashes for pyqt_checkbox_file_list_widget-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0135dea06a3a80fcb5608306fcb8750a7ca9604be506bf6e711b82090ae8b611 |
|
MD5 | 1bff8a8dae67fe5947e344f2a2af8d07 |
|
BLAKE2b-256 | 4f7184fcaebfde5c612380886e84fdca0dd984276e8bf178249f609081569993 |