ctkPathLineEdit can't find setCurrentFileExtension function?

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 ) 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?

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:

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:

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