Scribus Forums

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

Title: getText() returns nothing
Post by: zenkon on November 20, 2019, 09: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, 08: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, 12:50:50 pm
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, 01: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, 01:29:31 pm
Code: [Select]
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, 04: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, 06: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, 09: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, 02: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, 03: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, 06:27:49 pm
It works, thanks for your help.
Keep up the good work.