[PyQt] Access to lines of text on textEdit.

Algis Kabaila akabaila at pcug.org.au
Tue Sep 14 03:14:39 BST 2010


On Tuesday 14 September 2010 11:01:57 Algis Kabaila wrote:
> On Tuesday 14 September 2010 10:09:10 Hans-Peter Jansen wrote:
> > On Tuesday 14 September 2010, 01:54:01 Algis Kabaila wrote:
> > > Is it possible to access lines of text in a textEdit?  If so how can I
> > > find information about it?
> > 
> > Depending on document type, try this:
> > 	document().findBlockByLineNumber(lineNumber).text()
> > 
> > Pete

Alas, I was not able to use or find findBlockByLineNumber. May  be my workaround 
is not that bad. Given a plain Python program solver.py, the call from PyQt 
Gui with data in a textEdit window, might look as follows:

    def solveStructure(self):
        document = self.textEdit.toPlainText()
        document = unicode(document)
        doc = document.split('\n')
	solver(doc)

I thought that there may be a simple way to access the data in a textEdit line 
by line, as it is possible in Delphi (which I used to use before I "saw the 
light" and was converted to Linux and Python).

in the above an i-th line of doc can be accessed by "solver" as doc[i]. 

Pete, though I was not able to find the findBlockByLineNumber, thank you for 
giving me the information.  Greatly appreciated!

Al. 
-- 
OldAl
akabaila at pcug.org.au


More information about the PyQt mailing list