How to add a observer for monitoring slice views changes?

system: Windows 10
Slicer-version: 4.10.0
Hello,
I am trying to add a observer to monitor the number of slice views changes. But the right way was not found. Which node and event should be used ?
Slice views changes like this:
image
– to → image

I want to trigger my own method after the event has occurred.

Here is the method of slice views changes:

layoutManager = slicer.app.layoutManager()
      customLayout = """
                <layout type="vertical">
                <item>
                <layout type="horizontal">
                  <item splitSize="300">
                  <view class="vtkMRMLSliceNode" singletontag="Red">
                    <property name="orientation" action="default">Axial</property>
                    <property name="viewlabel" action="default">R</property>
                    <property name="viewcolor" action="default">#F34A33</property>
                  </view>
                  </item>
                  <item splitSize="300">
                  <view class="vtkMRMLSliceNode" singletontag="Red1">
                    <property name="orientation" action="default">Axial</property>
                    <property name="viewlabel" action="default">R</property>
                    <property name="viewcolor" action="default">#F34A33</property>
                  </view>
                  </item>
                </layout>
                </item>
                <item>
                <layout type="horizontal">
                  <item splitSize="300">
                    <view class="vtkMRMLSliceNode" singletontag="Red2">
                        <property name="orientation" action="default">Axial</property>
                        <property name="viewlabel" action="default">R</property>
                        <property name="viewcolor" action="default">#F34A33</property>
                    </view>
                  </item>
                  <item splitSize="300">
                    <view class="vtkMRMLSliceNode" singletontag="Red3">
                        <property name="orientation" action="default">Axial</property>
                        <property name="viewlabel" action="default">R</property>
                        <property name="viewcolor" action="default">#F34A33</property>
                    </view>
                  </item>
                </layout>
                </item>
                </layout>
                """
      # Built-in layout IDs are all below 100, so you can choose any large random number
      # for your custom layout ID.
      customLayoutId = 503

      layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)

      # Switch to the new custom layout
      layoutManager.setLayout(customLayoutId)
customLayout = """
                        <layout type="horizontal">
                          <item splitSize="500">
                          <view class="vtkMRMLSliceNode" singletontag="Red">
                            <property name="orientation" action="default">Axial</property>
                            <property name="viewlabel" action="default">R</property>
                            <property name="viewcolor" action="default">#F34A33</property>
                          </view>
                          </item>
                          <item splitSize="500">
                          <view class="vtkMRMLSliceNode" singletontag="Red1">
                            <property name="orientation" action="default">Axial</property>
                            <property name="viewlabel" action="default">R</property>
                            <property name="viewcolor" action="default">#F34A33</property>
                          </view>
                          </item>
                        </layout>
                        """
      # Built-in layout IDs are all below 100, so you can choose any large random number
      # for your custom layout ID.
      customLayoutId = 502

      layoutManager.layoutLogic().GetLayoutNode().AddLayoutDescription(customLayoutId, customLayout)

      # Switch to the new custom layout
      layoutManager.setLayout(customLayoutId)

Thank you for your help!

You can add an observer to layoutManager.layoutLogic().GetLayoutNode() to get notified about layout changes.

Thank you so much for your support lassoan!
I used the following method(slicer.util.getNode("Layout").AddObserver(vtk.vtkCommand.ModifiedEvent, callbackFunc)) to achieve what I want. But I don’t know if there will be other problems.