Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morefigs/pyqt-helper
Autogenerate getter and setter code for PyQt UI objects
https://github.com/morefigs/pyqt-helper
boilerplate code-generation getter pyqt pyqt5 python python3 setter ui
Last synced: 4 months ago
JSON representation
Autogenerate getter and setter code for PyQt UI objects
- Host: GitHub
- URL: https://github.com/morefigs/pyqt-helper
- Owner: morefigs
- License: mit
- Created: 2019-01-15T06:25:42.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-03T22:11:31.000Z (over 5 years ago)
- Last Synced: 2024-04-26T14:20:23.877Z (10 months ago)
- Topics: boilerplate, code-generation, getter, pyqt, pyqt5, python, python3, setter, ui
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-helper
PyQt Helper is a script for auto-generating boiler plate code for interacting with PyQt widgets, such as value getters and setters, widget connections, and slot functions.
Usage
-----`python pyqt_helper.py widgets.txt`
where `widgets.txt` is a text file containing a PyQt widget object name on each line e.g. `spinBox_distance`.
Example
-------Given a text file named `widgets.txt` containing the object name of `spinBox_distance`, the following code would be generated and saved to a Python file named `widgets_helper.py`:
```python
class WidgetsHelper:@property
def distance(self) -> int:
return self.ui.spinBox_distance.value()@distance.setter
def distance(self, value: int) -> None:
self.ui.spinBox_distance.setValue(value)@property
def distance_enabled(self) -> bool:
return self.ui.spinBox_distance.isEnabled()@distance_enabled.setter
def distance_enabled(self, enabled: bool) -> None:
self.ui.spinBox_distance.setEnabled(enabled)
```A PyQt UI class can then simply inherit `WidgetsHelper` to gain the provided functionality:
```python
class MyWindow(QMainWindow, WidgetsHelper):def method(self):
# enable the distance spin box and set its value to 100
self.distance_enabled = True
self.distance = 100
```