-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from ZEISS/20240719-add-progress-bar
Added ProgressBar
- Loading branch information
Showing
8 changed files
with
439 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# ProgressBar | ||
|
||
![Main window progress bar](progress_bar.png) | ||
|
||
|
||
## Short description | ||
|
||
This example shows how to display a progress bar at the bottom of the ZEISS INSPECT main window. | ||
|
||
There are two other variants of a progress bar: | ||
* A specific API is available for showing <a href="https://github.com/ZEISS/zeiss-inspect-app-examples/tree/main/AppExamples/scripted_actuals/ScriptedElementProgress">Scripted elements progress</a> in the ZEISS INSPECT main window | ||
* The <a href="https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/howtos/python_api_introduction/user_defined_dialogs.html#progress-bar-widget">Progress bar widget</a> is used to show progress in a user-defined dialog. | ||
|
||
## Highlights | ||
|
||
The following code example shows a progress bar: | ||
|
||
```{code-block} python | ||
import gom.api.progress | ||
import time | ||
with gom.api.progress.ProgressBar() as bar: | ||
bar.set_message('Counting atoms in the universe... ') | ||
for i in range(100): | ||
# Pretend to be busy... | ||
time.sleep(0.1) | ||
# Increase the progress | ||
bar.set_progress(i) | ||
bar.set_message("Getting bored - stopping!") | ||
time.sleep(5) | ||
``` | ||
|
||
* The progress bar is shown in a `with` context, which means that it will be removed if the `with` block is finished or aborted | ||
* You define a text for the progress bar with the method `set_message()`. This text can be changed later. | ||
* You set the stage of completion — which is shown as a number and as a vertical bar graph — with `set_progress()` | ||
|
||
## Related | ||
|
||
* <a href="https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/python_api/python_api.html#gom-api-progress-progressbar">gom.api.progress.ProgressBar</a> | ||
* <a href="https://github.com/ZEISS/zeiss-inspect-app-examples/tree/main/AppExamples/scripted_actuals/ScriptedElementProgress">ScriptedElementProgress</a> | ||
* <a href="https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/howtos/python_api_introduction/user_defined_dialogs.html#progress-bar-widget">User-defined dialogs - Progress bar widget</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
## ProgressBar | ||
|
||
This App is part of the [ZEISS INSPECT Python API App Examples](https://github.com/ZEISS/zeiss-inspect-app-examples/tree/main/AppExamples). | ||
|
||
See [App documentation](Documentation.md) for details. | ||
|
||
You can [download this App](https://software-store.zeiss.com/products/apps/ProgressBar) from the [ZEISS Quality Software Store](https://software-store.zeiss.com). | ||
|
||
The ZEISS INSPECT App develomment documentation can be found on [ZEISS IQS GitHub](https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/index.html). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"author": "Carl Zeiss GOM Metrology GmbH", | ||
"description": "This example shows how to display a progress bar at the bottom of the ZEISS INSPECT main window", | ||
"labels": [ | ||
], | ||
"licensing": { | ||
"licenses": [ | ||
], | ||
"product-codes": [ | ||
] | ||
}, | ||
"software-revision": "1742", | ||
"software-version": "ZEISS INSPECT 2025 RC", | ||
"tags": [ | ||
], | ||
"title": "ProgressBar", | ||
"uuid": "73fac189-b974-480c-97c5-6c3773a9831f", | ||
"version": "1.0.0" | ||
} |
25 changes: 25 additions & 0 deletions
25
AppExamples/misc/ProgressBar/scripts/progress_bar.metainfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"display_name": "progress_bar", | ||
"folded_blocks": [ | ||
], | ||
"icon": "", | ||
"iinspect_condition": "", | ||
"interactive": false, | ||
"main_menu_path": { | ||
"anchor": { | ||
"item": "", | ||
"submenu": [ | ||
], | ||
"type": "command" | ||
}, | ||
"script": "userscript.progress_bar", | ||
"submenu": [ | ||
] | ||
}, | ||
"multicreation_script": false, | ||
"script_check_type": "none", | ||
"script_element_type": "none", | ||
"show_in_iinspect": false, | ||
"show_in_menu": true, | ||
"uuid": "9b28a4cd-ee48-4dac-ac52-4d8c3a6ecb1e" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# progress_bar.py | ||
# | ||
# Example for controlling the progress bar in the ZEISS INSPECT main window | ||
# | ||
# Carl Zeiss GOM Metrology GmbH, 2024 | ||
# | ||
# This App is part of the ZEISS INSPECT Python API Examples: | ||
# https://zeissiqs.github.io/zeiss-inspect-addon-api/2025/python_examples/ | ||
# --- | ||
|
||
import gom | ||
import time | ||
import gom.api.progress | ||
|
||
# In this example, the progress bar is cancelled when the 'with' block is left | ||
print("Showing progress bar until end of 'with' block is reached...", end="") | ||
with gom.api.progress.ProgressBar() as bar: | ||
bar.set_message('Counting atoms in the universe... ') | ||
for i in range(100): | ||
# Pretend to be busy... | ||
time.sleep(0.1) | ||
# Increase the progress | ||
bar.set_progress(i) | ||
bar.set_message("Getting bored - stopping!") | ||
time.sleep(5) | ||
print(" done!") | ||
|
||
# In this example, the progress bar is cancelled by calling finish_progress() | ||
# while the 'with' block continues | ||
print("Showing progress bar until finish_progress() is called...", end="") | ||
with gom.api.progress.ProgressBar() as bar: | ||
bar.set_message('Counting coins in your pocket... ') | ||
for i in range(100): | ||
# Pretend to be busy... | ||
time.sleep(0.1) | ||
# Increase the progress | ||
bar.set_progress(i) | ||
bar.set_message("That's enough to buy a coffee - stoppping for a coffee break!") | ||
time.sleep(5) | ||
# Remove progress bar | ||
bar.finish_progress() | ||
print(" stopped by finish_progress()!") | ||
time.sleep(10) | ||
print("End of 'with' block reached.") |