# 3D Widget after show() has (0,0)-sized window until fully displayed

**URL:** <https://discourse.slicer.org/t/3d-widget-after-show-has-0-0-sized-window-until-fully-displayed/19567>\
**Category:** Development\
**Tags:** python\
**Created:** [September 8, 2021, 12:34pm UTC](https://discourse.slicer.org/t/3d-widget-after-show-has-0-0-sized-window-until-fully-displayed/19567 "2021-09-08T12:34:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![atracsys-sbt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/atracsys-sbt/32/11434_2.png) [@atracsys-sbt](https://discourse.slicer.org/u/atracsys-sbt)\
**Post date:** [September 8, 2021, 12:34pm UTC](https://discourse.slicer.org/t/3d-widget-after-show-has-0-0-sized-window-until-fully-displayed/19567/1 "2021-09-08T12:34:47Z")

</div>

Hi,  
In order to make a custom camera reset in a 3D widget (qMRMLThreeDWidget), I need to access the vtkRenderWindow size after the call for the widget to show().  
However, I noticed that the window size was (0,0) if performed shortly after the show(), likely due to the window not being fully rendered yet.  
I tried and failed with the following attempts:

```auto
widget.show()
widget.threeDView().renderWindow().WaitForCompletion()
size = widget.threeDView().renderWindow().GetSize() # sill is (0,0)

```

and

```auto
widget.show()
while not widget.visible:
  pass
size = widget.threeDView().renderWindow().GetSize() # sill is (0,0)

```

Is there a way to get the size only once the 3D widget is done rendering ? Perhaps with through a connect to a signal or an observer for an event ?  
Thanks for any help

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [September 8, 2021, 12:37pm UTC](https://discourse.slicer.org/t/3d-widget-after-show-has-0-0-sized-window-until-fully-displayed/19567/2 "2021-09-08T12:37:38Z")

</div>

You could try either `slicer.app.processEvents()` or use a `QTimer.singleShot` so the event loop has had a chance to run.

---

<div class="post-metadata">

**Author:** ![atracsys-sbt](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/atracsys-sbt/32/11434_2.png) [@atracsys-sbt](https://discourse.slicer.org/u/atracsys-sbt)\
**Post date:** [September 8, 2021, 12:43pm UTC](https://discourse.slicer.org/t/3d-widget-after-show-has-0-0-sized-window-until-fully-displayed/19567/3 "2021-09-08T12:43:46Z")

</div>

`slicer.app.processEvents()` worked, thanks !
