Skip to main content

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

https://user-images.githubusercontent.com/55078043/174435483-d6e8b57c-5b26-48fd-a5a7-454841e11d69.mp4

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqt-line-number-widget-0.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pyqt_line_number_widget-0.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file pyqt-line-number-widget-0.0.1.tar.gz.

File metadata

File hashes

Hashes for pyqt-line-number-widget-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5cae047377d6725024de2a1b04b15c1ae8d1d025e6d22b6bdbdec6a1c5c933cc
MD5 76ee2ab4e0f9a6a8781fde6c251bc128
BLAKE2b-256 8b5f80c9f1090bad48d4517537b6828395d6ca41d6383c75f472acfed36bd1f1

See more details on using hashes here.

File details

Details for the file pyqt_line_number_widget-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyqt_line_number_widget-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc1aa58d95f3484f44306f478b9f1ec7e1b5f5d9f52edc341d1ca4856ba19a52
MD5 ea6a93e3213cd75f3f8ef19d469309ab
BLAKE2b-256 2e0b7f50c578ac636164b5668afaa8d1415967574b46e79feba8cbad36af0761

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page