# Slicer doesn't print anything during for loops even with sys.stdout.flush()

**URL:** <https://discourse.slicer.org/t/slicer-doesnt-print-anything-during-for-loops-even-with-sys-stdout-flush/34914>\
**Category:** Development\
**Tags:** python\
**Created:** [March 15, 2024, 3:46pm UTC](https://discourse.slicer.org/t/slicer-doesnt-print-anything-during-for-loops-even-with-sys-stdout-flush/34914 "2024-03-15T15:46:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leadro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leadro/32/69678_2.png) [@leadro](https://discourse.slicer.org/u/leadro)\
**Post date:** [March 15, 2024, 3:46pm UTC](https://discourse.slicer.org/t/slicer-doesnt-print-anything-during-for-loops-even-with-sys-stdout-flush/34914/1 "2024-03-15T15:46:34Z")

</div>

I’m developing a 3DSlicer extension that includes very long processes (huge for loops). I’d like to show the progress with a progressbar (like tqdm) or at least print some progress information at each iteration but nothing is printed in Slicer’s python console before the end of the process.  
This is what I obtain with tqdm, but only at the end as previously said.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/6/5683964f89f96e9456d4878549255e568ed5de7d.png)

I would be grateful for any help!

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 15, 2024, 3:50pm UTC](https://discourse.slicer.org/t/slicer-doesnt-print-anything-during-for-loops-even-with-sys-stdout-flush/34914/2 "2024-03-15T15:50:05Z")

</div>

Have you tried adding slicer.app.processEvents() after each print statement to trigger the Qt update?
