# ctkPathLineEdit can't find setCurrentFileExtension function?

**URL:** <https://discourse.slicer.org/t/ctkpathlineedit-cant-find-setcurrentfileextension-function/17118>\
**Category:** Support\
**Tags:** python\
**Created:** [April 16, 2021, 2:15am UTC](https://discourse.slicer.org/t/ctkpathlineedit-cant-find-setcurrentfileextension-function/17118 "2021-04-16T02:15:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Teresa\_Gadda](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/teresa_gadda/32/9663_2.png) [@Teresa\_Gadda](https://discourse.slicer.org/u/Teresa_Gadda)\
**Post date:** [April 16, 2021, 2:15am UTC](https://discourse.slicer.org/t/ctkpathlineedit-cant-find-setcurrentfileextension-function/17118/1 "2021-04-16T02:15:40Z")

</div>

I’m trying to set up my own slicer extension and one of the things I want to do is to be able to load a file but restrict the allowed extensions (or at least make it easier to select the correct one). Other posts here helpfully pointed me to the ctkPathLineEdit() widget and I’m trying to implement the extension limitations but running into a strange problem. I believe the function I want is “setCurrentFileExtension” (shown [here](http://www.commontk.org/docs/html/classctkPathLineEdit.html#a01d413dfb401752b2022821c3c551f61) ) however the slicer python interactor (and my python extension) do not acknowledge this function. See this minimal example from the python interactor:

\>\>\> c = ctk.ctkPathLineEdit()  
\>\>\> c.setCurrentFileExtension(“jpg”)  
Traceback (most recent call last):  
File “\<console\>”, line 1, in \<module\>  
AttributeError: ctkPathLineEdit has no attribute named ‘setCurrentFileExtension’

I get the same error when running from my (otherwise functioning) custom extension. Any ideas what might be going on here? Or have recommendations for a workaround or alternative?

---

<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:** [April 16, 2021, 1:57pm UTC](https://discourse.slicer.org/t/ctkpathlineedit-cant-find-setcurrentfileextension-function/17118/2 "2021-04-16T13:57:03Z")

</div>

Yes, it looks like that method is not exposed for python. That class has a lot of methods that are C++ only, meaning it probably hasn’t been used much from python an nobody went through to make the public api available.

The declaration is here and probably it’s enough to add `Q_INVOKABLE` to the line:

> <https://github.com/commontk/CTK/blob/master/Libs/Widgets/ctkPathLineEdit.h#L206>

If you have your own build you can test it.

But it would be better to go through the class and add `Q_PROPERTY` or `Q_INVOKABLE` for any feature someone might want to use from python. Or make them `Q_SLOTS`.

Here’s an example of a class that is pretty completely exposed:

> <https://github.com/commontk/CTK/blob/master/Libs/Widgets/ctkColorDialog.h>

---

<div class="post-metadata">

**Author:** ![Teresa\_Gadda](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/teresa_gadda/32/9663_2.png) [@Teresa\_Gadda](https://discourse.slicer.org/u/Teresa_Gadda)\
**Post date:** [April 16, 2021, 4:43pm UTC](https://discourse.slicer.org/t/ctkpathlineedit-cant-find-setcurrentfileextension-function/17118/3 "2021-04-16T16:43:51Z")

</div>

Thanks for the help! I’ll give that a try.
