# Input option from command line

**URL:** <https://discourse.slicer.org/t/input-option-from-command-line/23991>\
**Category:** Development\
**Created:** [June 21, 2022, 4:01pm UTC](https://discourse.slicer.org/t/input-option-from-command-line/23991 "2022-06-21T16:01:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bserrano](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/bserrano/32/17034_2.png) [@bserrano](https://discourse.slicer.org/u/bserrano)\
**Post date:** [June 21, 2022, 4:01pm UTC](https://discourse.slicer.org/t/input-option-from-command-line/23991/1 "2022-06-21T16:01:59Z")

</div>

Hi,

I am working on a script and I need to ask the user some parameters. I am using the function input:

```auto
def func():
     option1 = input("Bla bla")
     option2 = input("Bla bla")
     option3 = input("Bla bla")

```

The first input is working but the following ones don’t. What I am doing wrong?  
Same code works outside the function.

---

<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:** [June 21, 2022, 4:41pm UTC](https://discourse.slicer.org/t/input-option-from-command-line/23991/2 "2022-06-21T16:41:20Z")

</div>

You can use a nice GUI widget to get additional inputs.

For a single input you can do this:

```auto
result = qt.QInputDialog().getText(None, "Some Title","Some description")

```

![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/b/9b748cdb00e333ef2f4b58beb532b7da8d2461cf.png)

If you need multiple inputs then you can put together a dialogbox with a few fields in 10-15 lines of Python code; or create a dialog in Qt Designer (menu: Edit / Application settings / Developer / Qt Designer → launch):

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/f/9f0a19bcee0f148daee8bbde32edc8785b1089da.png)

You can display the dialog and get the entered values like this:

```python
widget = slicer.util.loadUI(r'c:\D\S4\Base\QTGUI\Resources\UI\qSlicerSettingsUserInformationPanel.ui')
widget.show()
ui = slicer.util.childWidgetVariables(widget)
print(ui.NameLineEdit.text)

```

This widget does not have an OK/Cancel button but you can add them in Qt Designer.

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [June 21, 2022, 6:24pm UTC](https://discourse.slicer.org/t/input-option-from-command-line/23991/3 "2022-06-21T18:24:50Z")

</div>

We could also look into overriding the `input` and `raw_input` built-in function to display a dialog when running without `--testing` flag.

That said, to be robust, modules should provide default values and nicely handle the case of being executed as self-test.
