File: progress.py

package info (click to toggle)
magicgui 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 21,796 kB
  • sloc: python: 11,202; makefile: 11; sh: 9
file content (25 lines) | stat: -rw-r--r-- 729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""# Simple progress bar

A simple progress bar demo with magicgui.
"""

from time import sleep

from magicgui import magicgui
from magicgui.tqdm import trange

# if magicui.tqdm.tqdm or trange are used outside of a @magicgui function, (such as in
# interactive use in IPython), then they fall back to the standard terminal output


# If use inside of a magicgui-decorated function
# a progress bar widget will be added to the magicgui container
@magicgui(call_button=True, layout="horizontal")
def long_running(steps=10, delay=0.1):
    """Long running computation with range iterator."""
    # trange(steps) is a shortcut for `tqdm(range(steps))`
    for _i in trange(steps):
        sleep(delay)


long_running.show(run=True)