With this tool, you can now attach XML file tags to Python functions. To use, copy the pyifunc.py and NCommands.py files to your project.
First import the pyfunc.py
import pyifunc
next create a xml file for your components and read the content you can use read_file() function!
uicode = pyifunc.read_file('ui.xml')
Now is the time to create desired functions, You can do nothing but return a value. Like changing a database You can use this function prams to access given props.
def say_hello(name, lastname):
return f"Hello {name} {lastname}"
Next you need to create a interface for connect components to functions
api_component = {
'Sayhello': say_hello,
# ...
}
And end of all:
pyifunc.write_file('execute.txt', pyifunc.execute(uicode, api_components))
Now you can use the SayHello tag in the xml file and do the processing with Python.
<Sayhello name="Mohammad safa" lastname="kamali" />
-
This tool has problems and is very sensitive. For example, there must be a space before /.
-
Since this project was a practice project for me, this tool may not be suitable for large projects.
-
This project is completely free and you can even use it for commercial projects and modify it. Ideas and changes are welcome.