Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjg30737/pyqt-left-right-list-widget
PyQt QListWidget which can add QListWidgetItem consist of two words. One word is left-aligned, the other is right-aligned.
https://github.com/yjg30737/pyqt-left-right-list-widget
pyqt pyqt-examples pyqt-qlistwidget pyqt5 pyqt5-examples pyqt5-gui pyqt5-qlistwidget pyqt5-tutorial python python3 python37 qlistwidget qt
Last synced: about 2 months ago
JSON representation
PyQt QListWidget which can add QListWidgetItem consist of two words. One word is left-aligned, the other is right-aligned.
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-left-right-list-widget
- Owner: yjg30737
- License: mit
- Created: 2022-01-05T04:19:20.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-05T04:32:36.000Z (about 3 years ago)
- Last Synced: 2024-12-29T08:42:12.036Z (about 2 months ago)
- Topics: pyqt, pyqt-examples, pyqt-qlistwidget, pyqt5, pyqt5-examples, pyqt5-gui, pyqt5-qlistwidget, pyqt5-tutorial, python, python3, python37, qlistwidget, qt
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-left-right-list-widget
PyQt QListWidget which can add QListWidgetItem consist of two words. One word is left-aligned, the other is right-aligned.## Requirements
PyQt5 >= 5.8## Setup
```pip3 install git+https://github.com/yjg30737/pyqt-left-right-list-widget.git --upgrade```## Usage
```addLeftRightItem(left_str: str, right_str: str)``` to insert a pair of word at the end of the list widget.## Example
Code Sample
```python
from PyQt5.QtWidgets import QHBoxLayout, QApplication, \
QVBoxLayout, QPushButton, QWidgetfrom pyqt_left_right_list_widget import LeftRightListWidget
class LeftRightListWidgetTestExample(QWidget):
def __init__(self):
super().__init__()
self.__initUi()def __initUi(self):
delBtn = QPushButton('Delete')
delBtn.clicked.connect(self.__delete)lay = QHBoxLayout()
lay.addWidget(delBtn)
lay.setContentsMargins(0, 0, 0, 0)topWidget = QWidget()
topWidget.setLayout(lay)self.__listWidget = LeftRightListWidget()
# Add three pair of words
self.__listWidget.addLeftRightItem('Ganon', 'Villain')
self.__listWidget.addLeftRightItem('Zelda', 'Princess')
self.__listWidget.addLeftRightItem('Link', 'Hero')
lay = QHBoxLayout()
lay.addWidget(self.__listWidget)
lay.setContentsMargins(0, 0, 0, 0)bottomWidget = QWidget()
bottomWidget.setLayout(lay)lay = QVBoxLayout()
lay.addWidget(topWidget)
lay.addWidget(bottomWidget)mainWidget = QWidget()
mainWidget.setLayout(lay)self.setLayout(lay)
# Remove selected item
def __delete(self):
item = self.__listWidget.currentItem()
if item:
self.__listWidget.takeItem(self.__listWidget.currentRow())if __name__ == "__main__":
import sysapp = QApplication(sys.argv)
ex = LeftRightListWidgetTestExample()
ex.show()
sys.exit(app.exec_())
```Result
