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.
Example
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)
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.0.7.tar.gz
(8.1 kB
view details)
Built Distribution
ez_qt-1.0.7-py3-none-any.whl
(9.6 kB
view details)
File details
Details for the file ez_qt-1.0.7.tar.gz
.
File metadata
- Download URL: ez_qt-1.0.7.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51e9718a1cd23c130ba26f73916c926bccffe6d9c0512d9ed336ffa468e5c24d |
|
MD5 | e3ea66f2abd4ae8776eb423c6cff5e3d |
|
BLAKE2b-256 | 4aafb8853f1d22ca86952a88e3c61c4ad7e3efc57a5761321f32a396b76155d4 |
File details
Details for the file ez_qt-1.0.7-py3-none-any.whl
.
File metadata
- Download URL: ez_qt-1.0.7-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b982e526878533cd642b982e5a712c8bc0afc6c87e1958db5547f37e9a8baf7 |
|
MD5 | e118f7c963162df2ad84e48c4b60bb0a |
|
BLAKE2b-256 | 5d3f77540d23f7e4cabd596ebfcdab3d9af529942e58c0debadd54bebdf3058b |