Skip to content

Commit b744df7

Browse files
authored
Merge pull request #2 from marcohenning/develop
v1.0.1
2 parents 939fa65 + 5520737 commit b744df7

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

README.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PyQt Animated LineEdit
22

3-
[![PyPI](https://img.shields.io/badge/pypi-v1.0.0-blue)](https://pypi.org/project/pyqt-animated-line-edit)
3+
[![PyPI](https://img.shields.io/badge/pypi-v1.0.1-blue)](https://pypi.org/project/pyqt-animated-line-edit)
44
[![Python](https://img.shields.io/badge/python-3.7+-blue)](https://github.com/marcohenning/pyqt-animated-line-edit)
55
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/marcohenning/pyqt-animated-line-edit/blob/master/LICENSE)
66
[![Coverage](https://img.shields.io/badge/coverage-96%25-neon)](https://github.com/marcohenning/pyqt-animated-line-edit)
@@ -34,17 +34,59 @@ class Window(QMainWindow):
3434
super().__init__(parent=None)
3535

3636
# AnimatedLineEdit
37-
self.username = AnimatedLineEdit('Username', self)
38-
self.username.setBorderRadius(2)
39-
self.username.setPlaceholderFontSizeInner(10)
40-
self.username.setPlaceholderFontSizeOuter(8)
41-
self.username.setPadding(QMargins(12, 0, 12, 0))
37+
self.animated_line_edit = AnimatedLineEdit('Username', self)
38+
self.animated_line_edit.setBorderRadius(2)
39+
self.animated_line_edit.setPlaceholderFontSizeInner(10)
40+
self.animated_line_edit.setPlaceholderFontSizeOuter(8)
41+
self.animated_line_edit.setPadding(QMargins(12, 0, 12, 0))
4242
```
4343

4444
## Documentation
4545

4646
> **IMPORTANT:** <br>Styling of the widget must not be done by setting the stylesheet manually as the widget calculates the stylesheet itself and overrides it. Use the provided methods such as `setBackgroundColor()`, `setHoveredBackgroundColor()`, `setFocusedBackgroundColor()` and `setDisabledBackgroundColor()` instead.
4747
48+
* **Setting the placeholder text:**
49+
```python
50+
animated_line_edit.setPlaceholderText('Username')
51+
```
52+
53+
* **Setting the placeholder font family:**
54+
```python
55+
animated_line_edit.setPlaceholderFontFamily('Arial')
56+
```
57+
58+
* **Setting the placeholder font size (inside position):**
59+
```python
60+
animated_line_edit.setPlaceholderFontSizeInner(14)
61+
```
62+
63+
* **Setting the placeholder font size (outside position):**
64+
```python
65+
animated_line_edit.setPlaceholderFontSizeOuter(12)
66+
```
67+
68+
* **Setting the placeholder color (affects both positions if no color is set for the outside position):**
69+
```python
70+
animated_line_edit.setPlaceholderColor(QColor(0, 0, 0))
71+
```
72+
73+
* **Setting the placeholder color (outside position):**
74+
```python
75+
animated_line_edit.setPlaceholderColorOutside(QColor(0, 0, 0))
76+
```
77+
78+
* **Setting the placeholder transition duration:**
79+
```python
80+
animated_line_edit.setTransitionDuration(500)
81+
```
82+
83+
* **Setting the placeholder transition easing curve:**
84+
```python
85+
animated_line_edit.setEasingCurve(QEasingCurve.Type.Linear)
86+
```
87+
88+
**<br>All methods:**
89+
4890
| Method | Description |
4991
|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
5092
| `setPlaceholderText(self, text: str)` | Set the text displayed as placeholder |

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name='pyqt-animated-line-edit',
9-
version='1.0.0',
9+
version='1.0.1',
1010
author='Marco Henning',
1111
license='MIT',
1212
packages=find_namespace_packages(where="src"),

src/pyqt_animated_line_edit/animated_line_edit.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,13 @@ def setPlaceholderColor(self, color: QColor):
352352

353353
self.__placeholder_color = color
354354

355+
if self.hasFocus():
356+
self.__placeholder_color_current = (self.__placeholder_color_outside if
357+
self.__placeholder_color_outside is not None
358+
else self.__placeholder_color)
359+
else:
360+
self.__placeholder_color_current = self.__placeholder_color
361+
355362
def getPlaceholderColorOutside(self) -> QColor:
356363
"""Get the current placeholder text color for the outside position.
357364
If this is not set the color for the inside position will be used

0 commit comments

Comments
 (0)