Helper functions and classes to work with PySide6/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
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 PySide6.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-2.0.0.tar.gz
(9.8 kB
view details)
Built Distribution
ez_qt-2.0.0-py3-none-any.whl
(11.0 kB
view details)
File details
Details for the file ez_qt-2.0.0.tar.gz
.
File metadata
- Download URL: ez_qt-2.0.0.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10a08c0e9318055dfad195cccdcced898326f5310f2c8a0fa5cf65bdd0a233b9 |
|
MD5 | 4d7399fd2e21ed4787159d2f7cf02337 |
|
BLAKE2b-256 | 93b5c86b9a2c900dd6b454ca71c854d9be926bbb7a5511eea38d626423e0df14 |
File details
Details for the file ez_qt-2.0.0-py3-none-any.whl
.
File metadata
- Download URL: ez_qt-2.0.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1c10e559ff5f6eb30246de9a99956ff4ec6965151d4d2718470c7c25c94c776 |
|
MD5 | be9b924d0e1ddea04a1bb311abc97f5c |
|
BLAKE2b-256 | 3fbdcac6f0f9ac151d3b50b99823155981ea2c24f1c0c645f3e32e0e15798d82 |