Skip to main content

AutoResizingTextEdit is a simple Qt widget based on QTextEdit. Its purpose is to automatically adjust editor height to match the text, with the help of a layout it’s placed in.

It works with both Python 2 and Python 3 as well as PyQt 4 and PyQt 5 [2]

Status

The project has not undergone extensive testing on multiple platorms yet and should be considered alpha-quality. It’s already feature-complete though and, due to its simplicity and emphasis on working with Qt widget system rather than subverting it, should be safe for general use.

The code has only been tested on Arch Linux so far.

Installation

setup.py

The repository contains standard setup.py script (using setuptools). To install run:

python setup.py install --root=/your/python/site-packages/path --optimize=1

For a complete command reference see setuptools documentation.

PyPI

If you’re using pip you can install the package from PyPI repository: auto-resizing-text-edit on PyPI

pip install auto-resizing-text-edit

You can install the PyQt 4 versions that way as well:

pip install git+https://github.com/cameel/auto-resizing-text-edit.git@pyqt4-v0.1.0

AUR

If you’re using Arch Linux you can get a PKGBUILD from AUR: python-auto-resizing-text-edit in AUR

Dependencies

  • Python >= 2.7

  • PyQt 5 or PyQt 4 [1] [2]

Usage

It’s as simple as:

from auto_resizing_text_edit import AutoResizingTextEdit

editor = AutoResizingTextEdit()

The widget also provides a simple way to constrain its minimum width to a specific number of lines (provided that all the text in the editor uses the same font; if not, you’re on your own here):

editor.setMinimumLines(3)

That’s all there is to it. You put it in a layout and forget about it:

from PyQt5.QtWidgets import QWidget, QVBoxLayout

widget = QWidget()
editor.setParent(widget)

layout = QVBoxLayout(widget)
layout.addWidget(editor)
layout.addStretch()

widget.setLayout(layout)

If you need more or just want to see the editor in action, there are a few simple but complete examples in examples/ directory.

License

Copyright © Kamil Śliwak

Released under the MIT License.

Release files for auto-resizing-text-edit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for auto-resizing-text-edit 0.1.0
File Size Uploaded
auto-resizing-text-edit-0.1.0.tar.gz 5.7 kB Details

Release files / auto-resizing-text-edit-0.1.0.tar.gz

Download URL auto-resizing-text-edit-0.1.0.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
283d912b989d86160f047b7e987f3e2153f9f04e3f6f6e653456509df74d7507
BLAKE2b-256 checksum
How to use checksums
e537a1ba3535c212e9badc697f222c87e9878004c3dfdf6b4d11e1f1b70c0f27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page