Skip to main content

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

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.setFilenames([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

https://user-images.githubusercontent.com/55078043/145915698-c0e2550c-cdc9-4aaf-8e96-a729a8d8050f.mp4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt-checkbox-file-list-widget-0.0.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file pyqt-checkbox-file-list-widget-0.0.2.tar.gz.

File metadata

File hashes

Hashes for pyqt-checkbox-file-list-widget-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b1f1c538cd4dd90b294d024f348ead5f0cb62f81a2e426d140da16380b2c2b44
MD5 ff09e4d6959b77d85d3ca4afe9b8414f
BLAKE2b-256 b87b02caaaccd4255b44278c32ce3b1750fb69f55bf56bb6404aa8c709bc7e47

See more details on using hashes here.

File details

Details for the file pyqt_checkbox_file_list_widget-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt_checkbox_file_list_widget-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e7e250cffe4009dcc5fd1d6080166daebaf89b1b4c238eee010ce3b12d5fc639
MD5 348a72fa5cede3bc4bfe2f963b29b948
BLAKE2b-256 d97e9beff1687da0293f3c669afa6dfe5daa6024bb3a04204b4ce77f407e8678

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page