Skip to content

Commit

Permalink
Merge pull request #13 from ZEISS/20240719-add-progress-bar
Browse files Browse the repository at this point in the history
Added ProgressBar
  • Loading branch information
mprinkezs authored Aug 5, 2024
2 parents 44781c8 + 030c150 commit 66a08d2
Show file tree
Hide file tree
Showing 8 changed files with 439 additions and 0 deletions.
44 changes: 44 additions & 0 deletions AppExamples/misc/ProgressBar/doc/Documentation.md
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 &mdash; which is shown as a number and as a vertical bar graph &mdash; 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>
9 changes: 9 additions & 0 deletions AppExamples/misc/ProgressBar/doc/README.md
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).
Binary file added AppExamples/misc/ProgressBar/doc/progress_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AppExamples/misc/ProgressBar/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
296 changes: 296 additions & 0 deletions AppExamples/misc/ProgressBar/license/license.txt

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions AppExamples/misc/ProgressBar/metainfo.json
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 AppExamples/misc/ProgressBar/scripts/progress_bar.metainfo
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"
}
46 changes: 46 additions & 0 deletions AppExamples/misc/ProgressBar/scripts/progress_bar.py
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.")

0 comments on commit 66a08d2

Please sign in to comment.