# Raise only Add Files GUI

**URL:** <https://discourse.slicer.org/t/raise-only-add-files-gui/21290>\
**Category:** Development\
**Created:** [December 31, 2021, 10:54am UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290 "2021-12-31T10:54:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srijeet\_Chatterjee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/srijeet_chatterjee/32/12027_2.png) [@Srijeet\_Chatterjee](https://discourse.slicer.org/u/Srijeet_Chatterjee)\
**Post date:** [December 31, 2021, 10:54am UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/1 "2021-12-31T10:54:40Z")

</div>

Hello Everyone,

I want to create a simple button in a scripted (python) module,such that on clicked ideally that should raise the “Add Data” widget. Ideally I want it be preselected as the file loader only i.e the “Choose File(s) to Add” option. I research, but could not find a suitable solution for the Load. Would it be possible to do this using python?

Currently I could use the hot key combination as a work around, but “Choose File(s) to Add” option directly was not possible with that. Could anyone please suggest a better way to get this done?

Thanks a lot,  
Best regards,  
Srijeet

---

<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:** [January 2, 2022, 2:11am UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/2 "2022-01-02T02:11:40Z")

</div>

Can you tell a bit more about your workflow? What kind of files do your users load? How many at a time? Do they use drag-and-drop to load files? Do you want to entirely skip the “Add data” dialog (always want to load files with the default options)?

---

<div class="post-metadata">

**Author:** ![Srijeet\_Chatterjee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/srijeet_chatterjee/32/12027_2.png) [@Srijeet\_Chatterjee](https://discourse.slicer.org/u/Srijeet_Chatterjee)\
**Post date:** [January 2, 2022, 3:51am UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/3 "2022-01-02T03:51:49Z")

</div>

Thank you, the workflow mainly involves replay recorded video. The users would upload .mkv (description: IGISO) format video or sequences. Ideally one/two files to replay the recorded videos. Keeping the default options and removing the “Add Data” dialog option would be great.

Best Regards,  
Srijeet

---

<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:** [January 2, 2022, 8:29pm UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/4 "2022-01-02T20:29:58Z")

</div>

You can use `openDialog` method to show a file selector dialog and directly load the chosen file. See examples in the [script repository](https://github.com/Slicer/Slicer/blob/c57dd676fdcccacc8d40727c65e85eb118701ee7/Base/Python/slicer/util.py#L899).

For direct loading by drag-and-drop, you can register a drag-and-drop handler that can detect this specific file format and load the file directly (without opening the Add data window). See the DICOM module as an example, which does this for DICOM files.

---

<div class="post-metadata">

**Author:** ![Srijeet\_Chatterjee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/srijeet_chatterjee/32/12027_2.png) [@Srijeet\_Chatterjee](https://discourse.slicer.org/u/Srijeet_Chatterjee)\
**Post date:** [January 3, 2022, 2:48pm UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/6 "2022-01-03T14:48:50Z")

</div>

Thanks a lot, the `openDialog` method to show a file selector dialog works great. It’s even better because it restricts the user to only view supported file formats. However the file format as I mentioned are .mkv and those didn’t get loaded finally even after selecting and opening them (I tried both ‘SequenceFile’ and ‘VolumeFile’ as filetype).

---

<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:** [January 3, 2022, 3:42pm UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/7 "2022-01-03T15:42:49Z")

</div>

The file type is “IGSIO Sequence” - see here:

> <https://github.com/IGSIO/SlicerIGSIO/blob/master/SequenceIO/qSlicerSequenceIOReader.cxx#L85>

---

<div class="post-metadata">

**Author:** ![Srijeet\_Chatterjee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/srijeet_chatterjee/32/12027_2.png) [@Srijeet\_Chatterjee](https://discourse.slicer.org/u/Srijeet_Chatterjee)\
**Post date:** [January 3, 2022, 11:06pm UTC](https://discourse.slicer.org/t/raise-only-add-files-gui/21290/8 "2022-01-03T23:06:40Z")

</div>

That’s great, thank you so much! Now it works perfectly
