Skip to main content

Helper functions and classes to work with PySide2/PyQt5

Project description

🌴 EZ Qt

EZ Qt is a simple collection of helper functions for PySide/PyQt widgets.

Installation

pip install ez-qt

Setting themes for your app

You can use app_colors to style the colors of your app. The accent colors can be set as either a QColor, or you can use ez_qt.constants.AccentColors

Screenshot Screenshot

Constants

You can use the short notation k to use the constants in this package.

import ez_qt

my_background_color = ez_qt.k.BackgroundColors.dark_gray

Various Examples

import sys
from PySide2.QtWidgets import *
import ez_qt

class Form(QDialog):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle("EZ Qt")
        self.setMinimumWidth(400)
        self.setMinimumHeight(300)
        self.layout = QVBoxLayout()

        # make a combo box
        self.cb_items = QComboBox()

        # make a list to add to our combo box
        european = ["Stockholm", "Paris", "Rome"]
        ez_qt.combo_box.add_items(self.cb_items, european)

        # let's add some more, but without any duplicates
        entire_world = ["New York", "Tokyo", "Toronto", "Paris", "Brussels"]
        ez_qt.combo_box.add_items(self.cb_items, entire_world, duplicates_allowed=False)

        # let's add the continents as a string
        continents = "Europe, America, Africa, Oceania"
        ez_qt.combo_box.add_items(self.cb_items, continents, string_split_character=",")

        # let's set the combo box to "Toronto"
        ez_qt.combo_box.set_to_item(self.cb_items, "Toronto")

        # let's gather everything in the combo box as a list to use later
        all_geography = ez_qt.combo_box.get_all_items(self.cb_items)

        # adding a list widget
        self.lw_items = QListWidget()

        # Let's add the list we gathered earlier and add it to the list widget
        ez_qt.list_widget.add_items(self.lw_items, items=all_geography)

        # Now let's add a button that removes the selected item from the listwidget
        # It will then also update our combo box to reflect the same update
        self.btn_remove_selected = QPushButton("Remove selected item")
        self.btn_remove_selected.clicked.connect(self.remove_and_update)

        self.layout.addWidget(self.cb_items)
        # adding a horizontal line
        self.layout.addWidget(ez_qt.general.QHLine())
        self.layout.addWidget(self.lw_items)
        self.layout.addWidget(self.btn_remove_selected)

        self.setLayout(self.layout)

    def remove_and_update(self):
        # first remove the selected items
        ez_qt.list_widget.remove_items(self.lw_items, selected=True)

        # then get the remaining items as a list
        listwidget_items = ez_qt.list_widget.get_all_items(self.lw_items)

        # and update the combobox
        ez_qt.combo_box.add_items(self.cb_items, items=listwidget_items, clear=True)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    # set the colors for our app
    # ez_qt.app_colors.set_medium_theme(app, accent_color=ez_qt.k.AccentColors.medium_pink)
    ez_qt.app_colors.set_dark_theme(app, accent_color=ez_qt.k.AccentColors.medium_pink)
    form = Form()
    form.show()
    sys.exit(app.exec_())

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

ez_qt-1.1.2.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

ez_qt-1.1.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file ez_qt-1.1.2.tar.gz.

File metadata

  • Download URL: ez_qt-1.1.2.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for ez_qt-1.1.2.tar.gz
Algorithm Hash digest
SHA256 041234e661615cd521ed461f4bba28824b5dc1b44487a2f910f667b01fb64b7f
MD5 1c86df8dff8aafe2398acc165d742ff0
BLAKE2b-256 70d9bbef79d04d7baf5cc7b11c6b33a3cd615cbd104d1ad18a6a1efbaf834cc6

See more details on using hashes here.

File details

Details for the file ez_qt-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: ez_qt-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6

File hashes

Hashes for ez_qt-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c172355b77c16a77a2f449db5407b3f1d280becbb865f085aa0f531fdc5c2e44
MD5 b4f8a37bc6a5701bed3666e2eb4b905f
BLAKE2b-256 c771e51b60f021154a2e699d83ce7a4b17ebb05abeecf0c281d0cf116937148a

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