# Accessing 'ok' parameter from QInputDialog

**URL:** <https://discourse.slicer.org/t/accessing-ok-parameter-from-qinputdialog/35375>\
**Category:** Support\
**Tags:** python\
**Created:** [April 9, 2024, 2:00am UTC](https://discourse.slicer.org/t/accessing-ok-parameter-from-qinputdialog/35375 "2024-04-09T02:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruce](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bruce](https://discourse.slicer.org/u/bruce)\
**Post date:** [April 9, 2024, 2:00am UTC](https://discourse.slicer.org/t/accessing-ok-parameter-from-qinputdialog/35375/1 "2024-04-09T02:00:00Z")

</div>

Hello,  
I’m using a simple input dialog to get a user choice from a list but need to determine if the Cancel button has been pushed. I understand slicer uses PythonQt and it looks like PythonQt provides a BoolResult type to do this. However, I haven’t been able to get this working. The following code just causes slicer to crash.

```python
result = PythonQt.BoolResult()
item = qt.QInputDialog().getItem(None, "MyTitle", "Enter text", ['Choice1', 'Choice2'], ok=result)

```

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [April 9, 2024, 3:33am UTC](https://discourse.slicer.org/t/accessing-ok-parameter-from-qinputdialog/35375/2 "2024-04-09T03:33:39Z")

</div>

It was quite close. This works:

```python
import PythonQt
selectionSuccess = PythonQt.BoolResult()
selectedItem = PythonQt.QtGui.QInputDialog().getItem(None, "MyTitle", "Label", ['Choice1', 'Choice2'], 1, True, selectionSuccess)

```

Note that popup windows are generally very annoying for users and should only be used in exceptional cases. I would recommend to add these widgets to your module’s GUI panel instead (by using Qt Designer).

---

<div class="post-metadata">

**Author:** ![bruce](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@bruce](https://discourse.slicer.org/u/bruce)\
**Post date:** [April 11, 2024, 3:03am UTC](https://discourse.slicer.org/t/accessing-ok-parameter-from-qinputdialog/35375/3 "2024-04-11T03:03:53Z")

</div>

Perfect. Thank you.  
Yes, popup window is only to cater for low traffic pathway through the workflow (trying to avoid cluttering the module pane).
