# Progressbar in 3D Slicer python script - how can I make it stay in foreground?

**URL:** <https://discourse.slicer.org/t/progressbar-in-3d-slicer-python-script-how-can-i-make-it-stay-in-foreground/18280>\
**Category:** Support\
**Created:** [June 22, 2021, 6:58pm UTC](https://discourse.slicer.org/t/progressbar-in-3d-slicer-python-script-how-can-i-make-it-stay-in-foreground/18280 "2021-06-22T18:58:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [June 22, 2021, 6:58pm UTC](https://discourse.slicer.org/t/progressbar-in-3d-slicer-python-script-how-can-i-make-it-stay-in-foreground/18280/1 "2021-06-22T18:58:23Z")

</div>

Hi,

How can I make the progressbar created like this

```
    progressbar = slicer.util.createProgressDialog(windowTitle='Processing...', autoClose=False)
    progressbar.setCancelButton(None)
    progress =0
    steps = 7
    progressStep = 100/steps       
    # Update progress value
    progressbar.setValue(progress)
    progress += progressStep
    # Update label text
    progressbar.labelText = "Starting processing ..."
    slicer.app.processEvents()

```

. . .

stay in foreground? It is called from the process logic of my extension and keeps disappearing from the screen (Slicer switches itself to foreground) , from time to time

Thank you and best regards

Rudolf

---

<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:** [June 22, 2021, 11:07pm UTC](https://discourse.slicer.org/t/progressbar-in-3d-slicer-python-script-how-can-i-make-it-stay-in-foreground/18280/2 "2021-06-22T23:07:54Z")

</div>

In general, it is better to avoid popup windows and instead place all widgets in the module widget (and disable parts of the GUI that you want to prevent from being manipulated). If you want to use a popup window then set the application’s main window as parent to make sure it always appears above the main window.

---

<div class="post-metadata">

**Author:** ![rbumm](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rbumm/32/9404_2.png) [@rbumm](https://discourse.slicer.org/u/rbumm)\
**Post date:** [June 23, 2021, 7:02am UTC](https://discourse.slicer.org/t/progressbar-in-3d-slicer-python-script-how-can-i-make-it-stay-in-foreground/18280/3 "2021-06-23T07:02:51Z")

</div>

Thank you.  
This works for me now:

```auto
progressbar=slicer.util.createProgressDialog(parent=slicer.util.mainWindow(),windowTitle='Processing...',autoClose=False)

```
