How to add button on 2d or 3d window?


hello community,like the picture above, i want to add three pushbutton on the right bottom part of 2d window,how to do the work?

Good question - this code seems to work. You’d need to add some extra code if you want to have it show up in the lower right corner and track window resizes and things.

>>> sliceButton = qt.QPushButton("Slice")
>>> sliceButton.setParent(slicer.app.layoutManager().sliceWidget("Red"))
>>> sliceButton.geometry = qt.QRect(0,0,200,200)
>>> sliceButton.show()
>>> 

1 Like

thank you pieper! the code is very useful!