.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\itom\ui\demo_interrupt.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_itom_ui_demo_interrupt.py: Interrupt ============ .. GENERATED FROM PYTHON SOURCE LINES 5-28 .. code-block:: default from itom import ui import time gui = ui("interruptDemo.ui", ui.TYPEWINDOW) def do(): gui.btnDo["enabled"] = False try: # it is not possible to interrupt a simple sleep command # therefore, it is put into a loop over shorter sleeps... for i in range(0, 200): time.sleep(0.1) except KeyboardInterrupt: print("the sleep loop has been interrupted.") gui.btnDo["enabled"] = True raise gui.btnDo["enabled"] = True gui.btnDo.connect("clicked()", do) gui.btnInterrupt.invokeKeyboardInterrupt("clicked()") gui.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.157 seconds) .. _sphx_glr_download_11_demos_itom_ui_demo_interrupt.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_interrupt.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_interrupt.ipynb `