Scribus Forums

Scribus => Scripts and Plugins => Topic started by: zenkon on November 20, 2019, 08:55:57 PM

Title: getText() returns nothing
Post by: zenkon on November 20, 2019, 08:55:57 PM
Hey there,
i am really struggling with this one:
i call the getText function after selecting some text in a text frame but the function return a empty string even though I can set the color of the selected text.
Any ideas?

Thanks
Zenkon
Title: Re: getText() returns nothing
Post by: a.l.e on November 21, 2019, 07:53:06 AM
works here with the current scribus code...

which version of scribus are you using?
Title: Re: getText() returns nothing
Post by: zenkon on November 21, 2019, 11:50:50 AM
Hey,
thanks for your reply. I am using scribus 1.4.8 in a debian enviroment.
Title: Re: getText() returns nothing
Post by: a.l.e on November 21, 2019, 12:11:13 PM
hi

print(scribus.getText())

or

print(getText())

also work in my 1.4.8 with debian...
Title: Re: getText() returns nothing
Post by: zenkon on November 21, 2019, 12:29:31 PM

mainTextBox = scribus.createText(120.0,120.0,40.0,60.0)
scribus.insertText("Hello World",0,mainTextBox)
scribus.selectText(0,scribus.getTextLength(), mainTextBox)
text = scribus.getText()
print(text)
Title: Re: getText() returns nothing
Post by: a.l.e on November 21, 2019, 03:11:11 PM
oh! ah ah!

https://bugs.scribus.net/view.php?id=15911

<rant>people, please provide enough context in your questions!
attach sample .sla and .pdf files or, in this case, a script snippets that let us reproduce your issues...
... and, no, most of the time a screenshot is not enough...
life is so much easier when we don't have to rely on our crystal ball!</rant>

Title: Re: getText() returns nothing
Post by: zenkon on November 21, 2019, 05:41:44 PM
I am not really sure if I understand this correctly. It was a bug and it is now fixed in 1.5.6? But if so why does it work on your system? Sorry ^^
Title: Re: getText() returns nothing
Post by: Nermander on November 21, 2019, 08:04:55 PM
Probably because a.l.e did not create the text with insertText, but typed it manually in the document.

Nothing in the initial post said the text had been entered using insertText.
Title: Re: getText() returns nothing
Post by: zenkon on November 22, 2019, 01:43:18 PM
Ok, but is there a solution to my problem?
Title: Re: getText() returns nothing
Post by: a.l.e on November 22, 2019, 02:09:16 PM
yes, go and read the bug report i've linked above.
(small hint: getAllText())

or get the latest scribus and do an update after the insert.

ciao
a.l.e
Title: Re: getText() returns nothing
Post by: zenkon on November 22, 2019, 05:27:49 PM
It works, thanks for your help.
Keep up the good work.