Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yjg30737/pyqt-rounded-profile-image
PyQt rounded profile image like Youtube, Google, etc.
https://github.com/yjg30737/pyqt-rounded-profile-image
pyqt pyqt-examples pyqt-gui pyqt-tutorial pyqt5 pyqt5-examples pyqt5-gui pyqt5-tutorial python python3 qlabel qpixmap qt
Last synced: 4 days ago
JSON representation
PyQt rounded profile image like Youtube, Google, etc.
- Host: GitHub
- URL: https://github.com/yjg30737/pyqt-rounded-profile-image
- Owner: yjg30737
- License: mit
- Created: 2023-01-29T10:10:17.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-29T11:53:40.000Z (almost 2 years ago)
- Last Synced: 2024-10-19T02:16:28.420Z (about 1 month ago)
- Topics: pyqt, pyqt-examples, pyqt-gui, pyqt-tutorial, pyqt5, pyqt5-examples, pyqt5-gui, pyqt5-tutorial, python, python3, qlabel, qpixmap, qt
- Language: Python
- Homepage:
- Size: 2.3 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pyqt-rounded-profile-image
PyQt rounded profile image like Youtube, Google, etc.Profile image is `QLabel`. `QPixmap`'s `setMask` fucntion is being used to make the image rounded.
## Requirements
* PyQt5## Install
### clone
* git clone ~
* python sample.py
### as a package
* python -m pip install pyqt-rounded-profile-image## Method Overview
* `setImage(filename: str)` - Set the image file to the circle.## Example
### Code Sample
```python
import os.pathfrom PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QVBoxLayout, QFileDialogfrom pyqt_rounded_profile_image import RoundedImage
class Window(QWidget):
def __init__(self):
super().__init__()
self.__initUi()def __initUi(self):
self.__label = RoundedImage()
# maximum size has to be set
# otherwise, it will expand, regardless of the size policy setting
# half of the actual size is recommended
self.__label.setMaximumSize(128, 128)btn = QPushButton('Select the Image')
btn.clicked.connect(self.__update)lay = QVBoxLayout()
lay.addWidget(self.__label)
lay.addWidget(btn)
lay.setAlignment(Qt.AlignCenter)
self.setLayout(lay)
# set the image file name you want (as an default image)
self.__label.setImage('a.png')def __update(self):
# os.path.expanduser indicates the "Document" folder
filename = QFileDialog.getOpenFileName(self, 'Select the Image', os.path.expanduser('~'), 'Image Files (*.png *.jpg *.bmp)')
if filename[0]:
filename = filename[0]
self.__label.setImage(filename)if __name__ == "__main__":
import sysapp = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
```### Result
![image](https://user-images.githubusercontent.com/55078043/215319608-4c0e95dd-06f8-400d-8d51-ed516a49fe88.png)
You can select the image file to show (*.png, *.jpg, *.bmp)
There are two images (both two are Laurie Holden) in the root directory for testing the feature.
## TODO list
* Default image or text
* Popup window
* Animation
* Ensure that the edges are smoother, regardless of the size