# Pass interface variables between classes

**URL:** <https://discourse.slicer.org/t/pass-interface-variables-between-classes/31008>\
**Category:** Support\
**Created:** [August 6, 2023, 9:30am UTC](https://discourse.slicer.org/t/pass-interface-variables-between-classes/31008 "2023-08-06T09:30:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kening\_Zhang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kening_zhang/32/65641_2.png) [@Kening\_Zhang](https://discourse.slicer.org/u/Kening_Zhang)\
**Post date:** [August 6, 2023, 9:30am UTC](https://discourse.slicer.org/t/pass-interface-variables-between-classes/31008/1 "2023-08-06T09:30:38Z")

</div>

Dear developers，

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/1/f12d2be8b04241d0f94722ca02ad8a5fbe5e8356.png)  
I create a message box want to update the process phase of my code, I define it in Widget class, and it successfully show in interface,  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/9/d94e3f2cd87d310cc55a04c6054fbf7b3f0ce689.png)  
But the question is I need to update the state in Logic class,  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/2/b2a61e4ba5283f37e5e2070796f4872f48d22fc3.png)  
When I click apply, error showed,  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/1/1/1179266911b39e8a4c3121c4f4a0d226427949e3.png)  
So I want to know how to pass ui2 between different classes.

Best wishes,  
Joshua

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 6, 2023, 6:27pm UTC](https://discourse.slicer.org/t/pass-interface-variables-between-classes/31008/2 "2023-08-06T18:27:06Z")

</div>

We often include a `progressCallback` option in the Logic constructor that defaults to a noop (e.g. like `lambda x: None`). That way the logic code can operate with no GUI, e.g. in batch mode, but when the Widget provides a function that does GUI operations the user gets feedback.

---

<div class="post-metadata">

**Author:** ![Kening\_Zhang](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kening_zhang/32/65641_2.png) [@Kening\_Zhang](https://discourse.slicer.org/u/Kening_Zhang)\
**Post date:** [August 6, 2023, 6:46pm UTC](https://discourse.slicer.org/t/pass-interface-variables-between-classes/31008/3 "2023-08-06T18:46:09Z")

</div>

Sorry but I think I cannot understand it deeply.  
I want to show in the Slicer that user can know the stage of my code.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [August 6, 2023, 7:01pm UTC](https://discourse.slicer.org/t/pass-interface-variables-between-classes/31008/4 "2023-08-06T19:01:55Z")

</div>

See how it’s used here for example:

> <https://github.com/Slicer/Slicer/blob/7ef59614c2458e4f693ab77834e6726cf6ae0540/Modules/Scripted/DICOMLib/DICOMBrowser.py#L409>

You basically have a method in the Widget class that “knows” about the GUI that gets passed into the logic where there is no access to the GUI by default. That way the logic class can be used as needed with different UI feedback or none at all.
