Customize error of qMRMLSliceControllerWidget

Hi all,

I would like to customize of qMRMLSliceControllerWidget

My code is like this (there is no error), but it is not work well.
Especially, the QLabel is not change and the maximize Button is not hide

Can I get a solution for this?

for viewColor in ["Red", "Green", "Yellow"]:
  widgets2D = layoutManager.sliceWidget(viewColor).findChild("qMRMLSliceControllerWidget")
      
  sliderWidget = widgets2D.findChild("qMRMLSliderWidget")
  sliderWidget.setVisible(False)

  buttons2D = widgets2D.findChildren('QToolButton')

  for button in buttons2D:
    button.setVisible(False)

  viewLabel = widgets2D.findChild("QLabel", "ViewLabel")

    
  if viewColor == "Red":
    viewLabel.setText("Axial")  

  if viewColor == "Green":
    viewLabel.setText("Coronal")

  if viewColor == "Yellow":
    viewLabel.setText("Saggital")

  font = qt.QFont()
  font.setPointSize(12)
  font.setBold(True)
  viewLabel.setFont(font)

  viewLabel.setAlignment(qt.Qt.AlignLeft)
layoutManager=slicer.app.layoutManager()
for viewColor in ["Red", "Green", "Yellow"]:
  widgets2D = layoutManager.sliceWidget(viewColor).findChild("qMRMLSliceControllerWidget")
      
  sliderWidget = widgets2D.findChild("qMRMLSliderWidget")
  sliderWidget.setVisible(False)

  buttons2D=slicer.util.findChild(widgets2D, 'MaximizeViewButton')


  buttons2D.hide()

Using this code, it disappears like in the video and then reappears.

layoutManager = slicer.app.layoutManager()
twoDwidget = layoutManager.sliceWidget("Red")
twoDwidgetBar = twoDwidget.findChild("qMRMLSliceControllerWidget")
button = twoDwidgetBar.findChild("QToolButton", "MaximizeViewButton")
button.hide()

Maximize/restore button state is managed by the widget, so you won’t be able to permanently change visibility by low-level under-the-hood manipulations. Instead, you can hide the entire qMRMLViewControllerBar or implement a flag that allows disabling of the maximize/restore feature.

I got a soultion about it

for controllerBar in slicer.util.mainWindow().findChildren("qMRMLViewControllerBar"):
    controllerBar.showMaximizeViewButton = False

You may still be able to maximize the view by using the right-click menu or double-click on the view. That may show the maximize button again.

I think it works well. It dose not appear again.