In my custom module, the user can adjust the size and position of the image capture of the RGY slice view windows. I would like to implement a button that will show the area to be captured by accessing the QPainter of the slice view window and then drawing a red rectangle in that window.
Here is an example of the script I have been trying to use:
layoutManager = slicer.app.layoutManager()
greenView = layoutManager.sliceWidget(‘Green’).sliceView()
michelangelo = qt.QPainter(greenView)
mPen=qt.QPen(qt.Qt.red)
mPen.setWidth(5)
michelangelo.setPen(mPen)
michelangelo.drawRect(100,100,498,169)
greenView.render()
Nothing shows up after running the code.