Scribusoid

Author Topic: getText() returns nothing  (Read 653 times)

zenkon

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
getText() returns nothing
« 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

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2286
  • Karma: 29
    • the graphics lab
Re: getText() returns nothing
« Reply #1 on: November 21, 2019, 08:53:06 am »
works here with the current scribus code...

which version of scribus are you using?

zenkon

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: getText() returns nothing
« Reply #2 on: November 21, 2019, 12:50:50 pm »
Hey,
thanks for your reply. I am using scribus 1.4.8 in a debian enviroment.

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2286
  • Karma: 29
    • the graphics lab
Re: getText() returns nothing
« Reply #3 on: November 21, 2019, 01:11:13 pm »
hi

print(scribus.getText())

or

print(getText())

also work in my 1.4.8 with debian...

zenkon

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: getText() returns nothing
« Reply #4 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)

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2286
  • Karma: 29
    • the graphics lab
Re: getText() returns nothing
« Reply #5 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>


zenkon

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: getText() returns nothing
« Reply #6 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 ^^

Nermander

  • Hero Member
  • *****
  • Posts: 1336
  • Karma: 17
Re: getText() returns nothing
« Reply #7 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.

zenkon

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: getText() returns nothing
« Reply #8 on: November 22, 2019, 02:43:18 pm »
Ok, but is there a solution to my problem?

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2286
  • Karma: 29
    • the graphics lab
Re: getText() returns nothing
« Reply #9 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

zenkon

  • Newbie
  • *
  • Posts: 6
  • Karma: 0
  • Scribus User
Re: getText() returns nothing
« Reply #10 on: November 22, 2019, 06:27:49 pm »
It works, thanks for your help.
Keep up the good work.