How to set openfiledialog extension filter to PropertyFileIncluded property?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
How to set openfiledialog extension filter to PropertyFileIncluded property?
How to set an extension filter for the open file dialog that is invoked when the PropertyFileIncluded property is changed?
Re: How to set openfiledialog extension filter to PropertyFileIncluded property?
First of all the C++ class PropertyFileIncluded must be extended by a further class member like PropertyFile. This means that the private member must added and the suitable getter and setter methods
Now it's possible to change the filter in C++ but still not in Python. Therefore an option is to "overload" PropertyFileIncluded::setPyObject(). So, this method can be extended by also checking if the passed argument is a dict. If yes, it should check for the key "filter" and if available and the corresponding value is a string assign it to m_filter.
In Python it will be possible to change the filter with:
Code: Select all
std::string m_filter
Code: Select all
void setFilter(const std::string& filter);
std::string getFilter() const;
In Python it will be possible to change the filter with:
Code: Select all
feature.FileIncluded = {"filter" : "Svg files (*.svg *.SVG);;All files (*.*)"}
Re: How to set openfiledialog extension filter to PropertyFileIncluded property?
git commit 302d3f5b95
As a test to see how it works create a TechDraw page. The created object is called Template and you can change the file filters with:
As a test to see how it works create a TechDraw page. The created object is called Template and you can change the file filters with:
Code: Select all
App.ActiveDocument.Template.Template={"filter" : "Svg files (*.svg);;All files (*.*)"}
App.ActiveDocument.Template.PageResult={"filter" : "Svg files (*.svg);;All files (*.*)"}
Re: How to set openfiledialog extension filter to PropertyFileIncluded property?
I thought there was such a possibility in pure Python after all... As for C++, it is clear that there is such a possibility.
And when will this Feature be available in Python?
I know, It seems to be possible to output a message if the user has selected the wrong file, I saw something like this in the Arch workbench code, but this is not fine...
Last edited by Evgeniy on Wed Dec 07, 2022 1:53 pm, edited 2 times in total.
Re: How to set openfiledialog extension filter to PropertyFileIncluded property?
And when will this Feature be available in Python?
git commit 302d3f5b95
Re: How to set openfiledialog extension filter to PropertyFileIncluded property?
Thanks. Sorry I didn't pay attention to that.