QWidget which shows line numbers of QTextBrowser or QTextEdit
Project description
pyqt-line-number-widget
Show line numbers next to QTextBrowser or QTextEdit
Requirements
- PyQt5 >= 5.8
Setup
python -m pip install pyqt-line-number-widget
Example
Code Sample
from PyQt5.QtWidgets import QApplication, QHBoxLayout, QTextEdit, QWidget
from pyqt_line_number_widget import LineNumberWidget
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.__initUi()
def __initUi(self):
self.__te = QTextEdit()
self.__te.textChanged.connect(self.__line_widget_line_count_changed)
self.__lineWidget = LineNumberWidget(self.__te)
lay = QHBoxLayout()
lay.addWidget(self.__lineWidget)
lay.addWidget(self.__te)
self.setLayout(lay)
def __line_widget_line_count_changed(self):
if self.__lineWidget:
n = int(self.__te.document().lineCount())
self.__lineWidget.changeLineCount(n)
if __name__ == "__main__":
import sys
app = QApplication(sys.argv)
mainWindow = MainWindow()
mainWindow.show()
app.exec()
Result
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyqt-line-number-widget-0.0.1.tar.gz
.
File metadata
- Download URL: pyqt-line-number-widget-0.0.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cae047377d6725024de2a1b04b15c1ae8d1d025e6d22b6bdbdec6a1c5c933cc |
|
MD5 | 76ee2ab4e0f9a6a8781fde6c251bc128 |
|
BLAKE2b-256 | 8b5f80c9f1090bad48d4517537b6828395d6ca41d6383c75f472acfed36bd1f1 |
File details
Details for the file pyqt_line_number_widget-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: pyqt_line_number_widget-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc1aa58d95f3484f44306f478b9f1ec7e1b5f5d9f52edc341d1ca4856ba19a52 |
|
MD5 | ea6a93e3213cd75f3f8ef19d469309ab |
|
BLAKE2b-256 | 2e0b7f50c578ac636164b5668afaa8d1415967574b46e79feba8cbad36af0761 |