0

I'm using QScintilla to make my own notepad for fun in pyqt5 python. I was wandering if there is a way to get the number of lines of a QScintilla() widget?

Souvlaki42
  • 15
  • 8

1 Answers1

2

You have to use the lines() method, you can also use the linesChanged signal.

import sys
from PyQt5 import QtWidgets, Qsci


class Editor(Qsci.QsciScintilla):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setText("Foo\nBar")
        self.print_lines()

        self.linesChanged.connect(self.handle_lines_changed)

    def handle_lines_changed(self):
        self.print_lines()

    def print_lines(self):
        print("total lines: {}".format(self.lines()))


if __name__ == "__main__":

    app = QtWidgets.QApplication(sys.argv)
    w = Editor()
    w.resize(640, 480)
    w.show()
    sys.exit(app.exec_())
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Thank you for some reason autocomplete doesn't show me this function. Do you know how to enchant python/pyqt5 autocomplete for VSCode? – Souvlaki42 Mar 24 '22 at 16:59