This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Python Script: Displaying Layer Problem

Tags: None
(comma "," separated)
User avatar
ren062408
Registered Member
Posts
29
Karma
0
OS
Good day everyone,

Trying to set the visibility of a layer through python script. So I setup a quick document with "Layer 1", "Layer 2", and "Layer 3" nodes/layers. On "Layer 3", I had some brush strokes scattered across the canvas. Then I run this script:
Code: Select all
from krita import*
doc= Krita.instance().activeDocument()

nodeName = "Layer 3"
node = doc.nodeByName(nodeName)

node.setVisible(0)
#node.setVisible(1)

The "Layer 3" visibility is turning off without a problem but the weird part is, I can still see my strokes on the canvas.

Now on a different scenario, I set my "Layer 3" off by default and I run the code again, only this time, I set:
Code: Select all
#node.setVisible(0)
node.setVisible(1)

to turn the layer's visibility on. The weird part is still weird, now the strokes won't appear in the canvas, but as I make new strokes on top of the old ones, the strokes magically appears and after undoing my new strokes, the old strokes are now displaying correctly.

It appears I need something to refresh my screen or something? do the same things happen to you guys? anyone knows how to fix this display problem?
User avatar
TheraHedwig
KDE Developer
Posts
1794
Karma
10
OS
You need to run Document.refreshProjection() after changing layers or the like.
User avatar
ren062408
Registered Member
Posts
29
Karma
0
OS
TheraHedwig wrote:You need to run Document.refreshProjection() after changing layers or the like.

Perfect! Just what I needed :) Thank you very much this is awesome


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]