Skip to main content

A custom PyQt6 widget providing a multi-select combobox functionality for PyQt6 applications.

Project description

MultiSelectComboBox

MultiSelectComboBox is a custom widget built using PyQt6 that provides a dropdown combo box allowing users to select multiple items. This widget is particularly useful in scenarios where users need to select multiple options from a list.

Purpose

The primary purpose of MultiSelectComboBox is to offer a user-friendly interface for selecting multiple items from a list efficiently. It allows users to choose from a set of options and displays the selected items in a compact manner.

Features

  • Multiple Selection: Users can select multiple items from the dropdown list.
  • Customizable Display: The widget allows customization of the display format for both the selected items and the dropdown items.
  • Output Control: Users can control whether the output should be in the form of data or text.
  • Display Delimiter: Users can specify a custom delimiter to separate the displayed items.
  • Resizable: The widget dynamically adjusts its size to accommodate the selected items.
  • User-friendly Interface: The interface is designed to be intuitive, allowing users to easily select and deselect items.

See all features in documentation.

How to Use

To use the MultiSelectComboBox widget in your PyQt6 application, follow these steps:

  1. Installation: Install the package using pip:

    pip install pyqt6-multiselect-combobox
    
  2. Import: Import the MultiSelectComboBox class into your Python code:

    from pyqt6_multiselect_combobox import MultiSelectComboBox
    
  3. Initialization: Create an instance of MultiSelectComboBox:

    multi_select_combo_box = MultiSelectComboBox()
    
  4. Adding Items: Add items to the dropdown list using addItem() or addItems() methods:

    multi_select_combo_box.addItem("Item 1", "Data 1")
    multi_select_combo_box.addItem("Item 2", "Data 2")
    multi_select_combo_box.addItems(["Item 3", "Item 4"], ["Data 3", "Data 4"])
    
  5. Customization: Customize the display format, output type, and display delimiter as needed:

    multi_select_combo_box.setDisplayType("text")
    multi_select_combo_box.setOutputType("data")
    multi_select_combo_box.setDisplayDelimiter(", ")
    
  6. Event Handling: Handle events such as item selection and deselection if required.

  7. Accessing Selected Data: Retrieve the selected data using the currentData() method:

    selected_data = multi_select_combo_box.currentData()
    

Example

from PyQt6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from pyqt6_multiselect_combobox import MultiSelectComboBox

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("MultiSelectComboBox Example")
        
        central_widget = QWidget()
        layout = QVBoxLayout()
        central_widget.setLayout(layout)
        
        multi_select_combo_box = MultiSelectComboBox()
        multi_select_combo_box.addItems(["Apple", "Banana", "Orange"])
        
        layout.addWidget(multi_select_combo_box)
        self.setCentralWidget(central_widget)

if __name__ == "__main__":
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec()

Additional Notes

  • Compatibility: MultiSelectComboBox is compatible with PyQt6.
  • Feedback and Contributions: Feedback and contributions are welcome. Feel free to open an issue or submit a pull request on GitHub.
  • License: This package is provided under the MIT License.

For more detailed usage and customization options, refer to the documentation.

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

pyqt6-multiselect-combobox-1.1.1.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

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