Author Topic: What does redraw do?  (Read 380 times)

Truman

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
  • Scribus User
What does redraw do?
« on: January 25, 2022, 12:19:51 am »
I'm checking out scripts and often a standard I see has to do with redraw.

The only thing I know is that it is disabled for speed.

What does this command do exactly? How does enabling vs disabling it change anything?

RobSay

  • Newbie
  • *
  • Posts: 40
  • Karma: 0
  • Scribus User
Re: What does redraw do?
« Reply #1 on: February 05, 2022, 05:06:43 pm »
It literally determines whether or not the items being manipulated in the script will be drawn on the screen.

You can see this in the scripter console. Open a new document and then open scripter and run the following:
Code: [Select]
createText(10,10,100,100,"newTextFrame")
This will appear immediately.

Now run:
Code: [Select]
setRedraw(False)
createText(10,50,100,100,"anotherNewTextFrame")

Nothing appears on the screen - but the console reports the name of the item - this means it has been created.

Now run:
Code: [Select]
setRedraw(True)
[code]
The second frame now appears.

Basically redrawing the screen takes processing power - especially if what is being drawn is graphical such as an image. In large scripts setting redraw to false or explicitly controlling when to redraw can significantly reduce the overall time taken to execute the script the script.