pyqt-animated-line-edit


Namepyqt-animated-line-edit JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/marcohenning/pyqt-animated-line-edit
SummaryAn animated version of the QLineEdit widget for PyQt and PySide
upload_time2024-09-09 15:49:48
maintainerNone
docs_urlNone
authorMarco Henning
requires_python>=3.7
licenseMIT
keywords python pyqt qt lineedit
VCS
bugtrack_url
requirements QtPy
Travis-CI No Travis.
coveralls test coverage
            
# PyQt Animated LineEdit

[![PyPI](https://img.shields.io/badge/pypi-v1.0.1-blue)](https://pypi.org/project/pyqt-animated-line-edit)
[![Python](https://img.shields.io/badge/python-3.7+-blue)](https://github.com/marcohenning/pyqt-animated-line-edit)
[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/marcohenning/pyqt-animated-line-edit/blob/master/LICENSE)
[![Coverage](https://img.shields.io/badge/coverage-96%25-neon)](https://github.com/marcohenning/pyqt-animated-line-edit)
[![Build](https://img.shields.io/badge/build-passing-neon)](https://github.com/marcohenning/pyqt-animated-line-edit)

A modern and animated version of the QLineEdit widget for PyQt and PySide.

![Main](https://github.com/user-attachments/assets/267832aa-44a3-4532-aca9-7e3b393e8a4b)

## About

The widget is based on Qt's QLineEdit widget and improves it by animating the placeholder text between two positions. If the widget is not in focus and does not contain any text, the placeholder will be in the normal (inside) position. When the widget is focused, however, the placeholder text moves to the top of the widget (outside position), creating a gap in the border. If the widget loses focus and does not contain any text, the placeholder moves to the normal position again. If the widget contains text, the placeholder will stay in position. This way the placeholder is always visible. The widget is highly customizable with options such as changing the duration and easing curve of the animation and changing the font and color for both placeholder positions independently.

## Installation

```
pip install pyqt-animated-line-edit
```

## Example

```python
from PyQt6.QtCore import QMargins
from PyQt6.QtWidgets import QMainWindow
from pyqt_animated_line_edit import AnimatedLineEdit


class Window(QMainWindow):

    def __init__(self):
        super().__init__(parent=None)

        # AnimatedLineEdit
        self.animated_line_edit = AnimatedLineEdit('Username', self)
        self.animated_line_edit.setBorderRadius(2)
        self.animated_line_edit.setPlaceholderFontSizeInner(10)
        self.animated_line_edit.setPlaceholderFontSizeOuter(8)
        self.animated_line_edit.setPadding(QMargins(12, 0, 12, 0))
```

## Documentation

> **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.

* **Setting the placeholder text:**
```python
animated_line_edit.setPlaceholderText('Username')
```

* **Setting the placeholder font family:**
```python
animated_line_edit.setPlaceholderFontFamily('Arial')
```

* **Setting the placeholder font size (inside position):**
```python
animated_line_edit.setPlaceholderFontSizeInner(14)
```

* **Setting the placeholder font size (outside position):**
```python
animated_line_edit.setPlaceholderFontSizeOuter(12)
```

* **Setting the placeholder color (affects both positions if no color is set for the outside position):**
```python
animated_line_edit.setPlaceholderColor(QColor(0, 0, 0))
```

* **Setting the placeholder color (outside position):**
```python
animated_line_edit.setPlaceholderColorOutside(QColor(0, 0, 0))
```

* **Setting the placeholder transition duration:**
```python
animated_line_edit.setTransitionDuration(500)
```

* **Setting the placeholder transition easing curve:**
```python
animated_line_edit.setEasingCurve(QEasingCurve.Type.Linear)
```

**<br>All methods:**

| Method                                                  | Description                                                                                                 |
|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `setPlaceholderText(self, text: str)`                   | Set the text displayed as placeholder                                                                       |
| `setTransitionDuration(self, duration: int)`            | Set the duration of the placeholder transition animation                                                    |
| `setEasingCurve(self, easing_curve: QEasingCurve.Type)` | Set the easing curve of the placeholder transition animation                                                |
| `setPlaceholderColor(self, color: QColor)`              | Set the color of the placeholder text (for both positions if the color for the outside position is not set) |
| `setPlaceholderColorOutside(self, color: QColor)`       | Set the color of the placeholder text for the outside position                                              |
| `setPlaceholderFontFamily(self, family: str)`           | Set the font family of the placeholder text (both positions)                                                |
| `setPlaceholderFontSizeInner(self, size: int)`          | Set the font size of the placeholder text for the inside position                                           |
| `setPlaceholderFontSizeOuter(self, size: int)`          | Set the font size of the placeholder text for the outside position                                          |
| `setPlaceholderFontBold(self, enable: bool)`            | Set the weight of the placeholder text to be bold or regular                                                |
| `setPlaceholderFontItalic(self, enable: bool)`          | Set the placeholder text to be italic or regular                                                            |
| `setColor(self, color: QColor)`                         | Set the regular color of the text                                                                           |
| `setBackgroundColor(self, color: QColor)`               | Set the regular color of the background                                                                     |
| `setBorderColor(self, color: QColor)`                   | Set the regular color of the border                                                                         |
| `setBorderWidth(self, width: int)`                      | Set the regular width of the border                                                                         |
| `setBorderRadius(self, radius: int)`                    | Set the radius of the border                                                                                |
| `setPadding(self, padding: QMargins)`                   | Set the padding of the widget                                                                               |
| `setHoveredColor(self, color: QColor)`                  | Set the text color for when the widget is hovered over                                                      |
| `setHoveredBackgroundColor(self, color: QColor)`        | Set the background color for when the widget is hovered over                                                |
| `setHoveredBorderColor(self, color: QColor)`            | Set the border color for when the widget is hovered over                                                    |
| `setHoveredBorderWidth(self, width: int)`               | Set the border width for when the widget is hovered over                                                    |
| `setFocusedColor(self, color: QColor)`                  | Set the text color for when the widget is focused                                                           |
| `setFocusedBackgroundColor(self, color: QColor)`        | Set the background color for when the widget is focused                                                     |
| `setFocusedBorderColor(self, color: QColor)`            | Set the border color for when the widget is focused                                                         |
| `setFocusedBorderWidth(self, width: int)`               | Set the border width for when the widget is focused                                                         |
| `setDisabledColor(self, color: QColor)`                 | Set the text color for when the widget is disabled                                                          |
| `setDisabledBackgroundColor(self, color: QColor)`       | Set the background color for when the widget is disabled                                                    |
| `setDisabledBorderColor(self, color: QColor)`           | Set the border color for when the widget is disabled                                                        |
| `setDisabledBorderWidth(self, width: int)`              | Set the border width for when the widget is disabled                                                        |

## License

This software is licensed under the [MIT license](https://github.com/marcohenning/pyqt-animated-line-edit/blob/master/LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/marcohenning/pyqt-animated-line-edit",
    "name": "pyqt-animated-line-edit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "python, pyqt, qt, lineedit",
    "author": "Marco Henning",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/57/f3/5a2ec9afeda9d4bfc36b5403dfa2a44c379bfa0843da736e08be89b1f3ae/pyqt-animated-line-edit-1.0.1.tar.gz",
    "platform": null,
    "description": "\r\n# PyQt Animated LineEdit\r\n\r\n[![PyPI](https://img.shields.io/badge/pypi-v1.0.1-blue)](https://pypi.org/project/pyqt-animated-line-edit)\r\n[![Python](https://img.shields.io/badge/python-3.7+-blue)](https://github.com/marcohenning/pyqt-animated-line-edit)\r\n[![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/marcohenning/pyqt-animated-line-edit/blob/master/LICENSE)\r\n[![Coverage](https://img.shields.io/badge/coverage-96%25-neon)](https://github.com/marcohenning/pyqt-animated-line-edit)\r\n[![Build](https://img.shields.io/badge/build-passing-neon)](https://github.com/marcohenning/pyqt-animated-line-edit)\r\n\r\nA modern and animated version of the QLineEdit widget for PyQt and PySide.\r\n\r\n![Main](https://github.com/user-attachments/assets/267832aa-44a3-4532-aca9-7e3b393e8a4b)\r\n\r\n## About\r\n\r\nThe widget is based on Qt's QLineEdit widget and improves it by animating the placeholder text between two positions. If the widget is not in focus and does not contain any text, the placeholder will be in the normal (inside) position. When the widget is focused, however, the placeholder text moves to the top of the widget (outside position), creating a gap in the border. If the widget loses focus and does not contain any text, the placeholder moves to the normal position again. If the widget contains text, the placeholder will stay in position. This way the placeholder is always visible. The widget is highly customizable with options such as changing the duration and easing curve of the animation and changing the font and color for both placeholder positions independently.\r\n\r\n## Installation\r\n\r\n```\r\npip install pyqt-animated-line-edit\r\n```\r\n\r\n## Example\r\n\r\n```python\r\nfrom PyQt6.QtCore import QMargins\r\nfrom PyQt6.QtWidgets import QMainWindow\r\nfrom pyqt_animated_line_edit import AnimatedLineEdit\r\n\r\n\r\nclass Window(QMainWindow):\r\n\r\n    def __init__(self):\r\n        super().__init__(parent=None)\r\n\r\n        # AnimatedLineEdit\r\n        self.animated_line_edit = AnimatedLineEdit('Username', self)\r\n        self.animated_line_edit.setBorderRadius(2)\r\n        self.animated_line_edit.setPlaceholderFontSizeInner(10)\r\n        self.animated_line_edit.setPlaceholderFontSizeOuter(8)\r\n        self.animated_line_edit.setPadding(QMargins(12, 0, 12, 0))\r\n```\r\n\r\n## Documentation\r\n\r\n> **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.\r\n\r\n* **Setting the placeholder text:**\r\n```python\r\nanimated_line_edit.setPlaceholderText('Username')\r\n```\r\n\r\n* **Setting the placeholder font family:**\r\n```python\r\nanimated_line_edit.setPlaceholderFontFamily('Arial')\r\n```\r\n\r\n* **Setting the placeholder font size (inside position):**\r\n```python\r\nanimated_line_edit.setPlaceholderFontSizeInner(14)\r\n```\r\n\r\n* **Setting the placeholder font size (outside position):**\r\n```python\r\nanimated_line_edit.setPlaceholderFontSizeOuter(12)\r\n```\r\n\r\n* **Setting the placeholder color (affects both positions if no color is set for the outside position):**\r\n```python\r\nanimated_line_edit.setPlaceholderColor(QColor(0, 0, 0))\r\n```\r\n\r\n* **Setting the placeholder color (outside position):**\r\n```python\r\nanimated_line_edit.setPlaceholderColorOutside(QColor(0, 0, 0))\r\n```\r\n\r\n* **Setting the placeholder transition duration:**\r\n```python\r\nanimated_line_edit.setTransitionDuration(500)\r\n```\r\n\r\n* **Setting the placeholder transition easing curve:**\r\n```python\r\nanimated_line_edit.setEasingCurve(QEasingCurve.Type.Linear)\r\n```\r\n\r\n**<br>All methods:**\r\n\r\n| Method                                                  | Description                                                                                                 |\r\n|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|\r\n| `setPlaceholderText(self, text: str)`                   | Set the text displayed as placeholder                                                                       |\r\n| `setTransitionDuration(self, duration: int)`            | Set the duration of the placeholder transition animation                                                    |\r\n| `setEasingCurve(self, easing_curve: QEasingCurve.Type)` | Set the easing curve of the placeholder transition animation                                                |\r\n| `setPlaceholderColor(self, color: QColor)`              | Set the color of the placeholder text (for both positions if the color for the outside position is not set) |\r\n| `setPlaceholderColorOutside(self, color: QColor)`       | Set the color of the placeholder text for the outside position                                              |\r\n| `setPlaceholderFontFamily(self, family: str)`           | Set the font family of the placeholder text (both positions)                                                |\r\n| `setPlaceholderFontSizeInner(self, size: int)`          | Set the font size of the placeholder text for the inside position                                           |\r\n| `setPlaceholderFontSizeOuter(self, size: int)`          | Set the font size of the placeholder text for the outside position                                          |\r\n| `setPlaceholderFontBold(self, enable: bool)`            | Set the weight of the placeholder text to be bold or regular                                                |\r\n| `setPlaceholderFontItalic(self, enable: bool)`          | Set the placeholder text to be italic or regular                                                            |\r\n| `setColor(self, color: QColor)`                         | Set the regular color of the text                                                                           |\r\n| `setBackgroundColor(self, color: QColor)`               | Set the regular color of the background                                                                     |\r\n| `setBorderColor(self, color: QColor)`                   | Set the regular color of the border                                                                         |\r\n| `setBorderWidth(self, width: int)`                      | Set the regular width of the border                                                                         |\r\n| `setBorderRadius(self, radius: int)`                    | Set the radius of the border                                                                                |\r\n| `setPadding(self, padding: QMargins)`                   | Set the padding of the widget                                                                               |\r\n| `setHoveredColor(self, color: QColor)`                  | Set the text color for when the widget is hovered over                                                      |\r\n| `setHoveredBackgroundColor(self, color: QColor)`        | Set the background color for when the widget is hovered over                                                |\r\n| `setHoveredBorderColor(self, color: QColor)`            | Set the border color for when the widget is hovered over                                                    |\r\n| `setHoveredBorderWidth(self, width: int)`               | Set the border width for when the widget is hovered over                                                    |\r\n| `setFocusedColor(self, color: QColor)`                  | Set the text color for when the widget is focused                                                           |\r\n| `setFocusedBackgroundColor(self, color: QColor)`        | Set the background color for when the widget is focused                                                     |\r\n| `setFocusedBorderColor(self, color: QColor)`            | Set the border color for when the widget is focused                                                         |\r\n| `setFocusedBorderWidth(self, width: int)`               | Set the border width for when the widget is focused                                                         |\r\n| `setDisabledColor(self, color: QColor)`                 | Set the text color for when the widget is disabled                                                          |\r\n| `setDisabledBackgroundColor(self, color: QColor)`       | Set the background color for when the widget is disabled                                                    |\r\n| `setDisabledBorderColor(self, color: QColor)`           | Set the border color for when the widget is disabled                                                        |\r\n| `setDisabledBorderWidth(self, width: int)`              | Set the border width for when the widget is disabled                                                        |\r\n\r\n## License\r\n\r\nThis software is licensed under the [MIT license](https://github.com/marcohenning/pyqt-animated-line-edit/blob/master/LICENSE).\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An animated version of the QLineEdit widget for PyQt and PySide",
    "version": "1.0.1",
    "project_urls": {
        "Homepage": "https://github.com/marcohenning/pyqt-animated-line-edit"
    },
    "split_keywords": [
        "python",
        " pyqt",
        " qt",
        " lineedit"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "41aa15b954795fc3ea0e457a42b14f767c4e10a1d9265a828bd1dc24999bc99f",
                "md5": "451da09bb8c8287ef7bf7449e130d2a5",
                "sha256": "2b1a042a2e997ea000e11af5159b41350f778bb417d4f208103e4d6eceefec47"
            },
            "downloads": -1,
            "filename": "pyqt_animated_line_edit-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "451da09bb8c8287ef7bf7449e130d2a5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8014,
            "upload_time": "2024-09-09T15:49:47",
            "upload_time_iso_8601": "2024-09-09T15:49:47.305152Z",
            "url": "https://files.pythonhosted.org/packages/41/aa/15b954795fc3ea0e457a42b14f767c4e10a1d9265a828bd1dc24999bc99f/pyqt_animated_line_edit-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "57f35a2ec9afeda9d4bfc36b5403dfa2a44c379bfa0843da736e08be89b1f3ae",
                "md5": "b959e10e6cbc8d7f5fee882c526fd445",
                "sha256": "044546e8977dcf56a250452778520a45b4874946a7c1d1637b2a18be5b8ab514"
            },
            "downloads": -1,
            "filename": "pyqt-animated-line-edit-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b959e10e6cbc8d7f5fee882c526fd445",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9284,
            "upload_time": "2024-09-09T15:49:48",
            "upload_time_iso_8601": "2024-09-09T15:49:48.525347Z",
            "url": "https://files.pythonhosted.org/packages/57/f3/5a2ec9afeda9d4bfc36b5403dfa2a44c379bfa0843da736e08be89b1f3ae/pyqt-animated-line-edit-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-09 15:49:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "marcohenning",
    "github_project": "pyqt-animated-line-edit",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "requirements": [
        {
            "name": "QtPy",
            "specs": [
                [
                    ">=",
                    "2.4.1"
                ]
            ]
        }
    ],
    "lcname": "pyqt-animated-line-edit"
}
        
Elapsed time: 0.30695s