# Screenshotting a hidden external view widget

**URL:** https://discourse.slicer.org/t/screenshotting-a-hidden-external-view-widget/19258
**Category:** Development
**Created:** [August 18, 2021, 3:24pm UTC](https://discourse.slicer.org/t/screenshotting-a-hidden-external-view-widget/19258 "2021-08-18T15:24:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nathanbmnt](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@nathanbmnt](https://discourse.slicer.org/u/nathanbmnt)
#### Post date: [August 18, 2021, 3:24pm UTC](https://discourse.slicer.org/t/screenshotting-a-hidden-external-view-widget/19258/1 "2021-08-18T15:24:18Z")

</div>

Hello,  
I have an external view widget I created with the code [here](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#show-a-slice-view-outside-the-view-layout) but I never call viewWidget.show() because I want it hidden from the user.

If I try to get a screenshot of the external slice view widget with `vtkWindowToImageFilter` the vtkImage is of size 0,0,1. If I use `img = ctk.ctkWidgetsUtils.grabWidget` the image is the right size and shows the colored scroll bar on top, but the slice image is completely black.

I always call slicer.app.processEvents and `view_widget.sliceView().forceRender()` before screenshotting but it still doesn’t function. Any suggestions?

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/0/2/02b21ad3d4291f34f203a7c12e801577c6b4b7c4.png)

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [August 18, 2021, 6:13pm UTC](https://discourse.slicer.org/t/screenshotting-a-hidden-external-view-widget/19258/2 "2021-08-18T18:13:47Z")

</div>

You may need to show the widget at least once to complete its initialization. You might also need to temporarily show it when you take a screenshot, in which case you could try set the window position outside of the screen or below the main window to prevent it from popping up for the user.

---

<div class="post-metadata">

### Author: ![nathanbmnt](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@nathanbmnt](https://discourse.slicer.org/u/nathanbmnt)
#### Post date: [August 18, 2021, 7:03pm UTC](https://discourse.slicer.org/t/screenshotting-a-hidden-external-view-widget/19258/3 "2021-08-18T19:03:01Z")

</div>

Showing the widget and then immediately hiding it right after creation does not work unfortunately. I can however screenshot when the widget is outside of the monitor bounds, so I’ve just used qwidget.setGeometry to put it out of bounds
