# Cancel CLI module running from a loadable scripted module through clicking the cancel button of qProgressDialog

**URL:** <https://discourse.slicer.org/t/cancel-cli-module-running-from-a-loadable-scripted-module-through-clicking-the-cancel-button-of-qprogressdialog/18330>\
**Category:** Support\
**Tags:** python, cli\
**Created:** [June 24, 2021, 5:35pm UTC](https://discourse.slicer.org/t/cancel-cli-module-running-from-a-loadable-scripted-module-through-clicking-the-cancel-button-of-qprogressdialog/18330 "2021-06-24T17:35:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bywbilly](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@bywbilly](https://discourse.slicer.org/u/bywbilly)\
**Post date:** [June 24, 2021, 5:35pm UTC](https://discourse.slicer.org/t/cancel-cli-module-running-from-a-loadable-scripted-module-through-clicking-the-cancel-button-of-qprogressdialog/18330/1 "2021-06-24T17:35:45Z")

</div>

Hi,

I run a CLI module in the background in a customized loadable scripted module. And following here [How to update the progress bar from a scripted CLI - #2 by strider\_hunter](https://discourse.slicer.org/t/how-to-update-the-progress-bar-from-a-scripted-cli/3789/2), I create a progressDialog to show the progress.

Now I would like to know when the user clicks the cancel button of the progress bar so I can call cliNode.cancel() to kill the process of the CLI module. I checked the Status of clicking cancel but it is the same with interpreting the XML file (both are 2). So I am wondering how can I achieve this goal?

Thanks!

---

<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 24, 2021, 6:52pm UTC](https://discourse.slicer.org/t/cancel-cli-module-running-from-a-loadable-scripted-module-through-clicking-the-cancel-button-of-qprogressdialog/18330/2 "2021-06-24T18:52:12Z")

</div>

Hi,

maybe this link helps:

> [@Use progress bar from python](https://discourse.slicer.org/t/use-progress-bar-from-python/4343/2):
>
> You can use this convenience function for that See example of usage here

see the usage of `progress.wasCanceled`

In my extension, I only use the naked progressbar without the Cancel button.

Best  
Rudolf

---

<div class="post-metadata">

**Author:** ![bywbilly](https://avatars.discourse-cdn.com/v4/letter/b/7bcc69/32.png) [@bywbilly](https://discourse.slicer.org/u/bywbilly)\
**Post date:** [June 29, 2021, 5:01pm UTC](https://discourse.slicer.org/t/cancel-cli-module-running-from-a-loadable-scripted-module-through-clicking-the-cancel-button-of-qprogressdialog/18330/3 "2021-06-29T17:01:05Z")

</div>

Hi Rudolf,

Thanks for the point. I didn’t make it work through wasCanceled. But I create another button for the GUI to cancel the process through cli\_node.Cancel(), which works perfectly.
