I mention in a github issue but I thought I should mention it here as well. There is a fault in the LVGL code surrounding callbacks. There are structures that have more than one field that can be filled with a callback but there is only a single user_data field. This will not work because I am only able to fill that user_data slot with a single handle from a python function. that means whatever callback gets placed last is going to be the one that ends up getting called for all of the callbacks in that structure. There is no way to supply more than one handle and there is no way to tell which callback is actually being used.
instead of placing a function pointer directly into those structures a new structure needs to be created for each callback and in that structure would be the function pointer and also a dedicated user_data field for that callback. That is the only way I can see this working properly. The other option is going to be setting user_data as an array but it will become complex to keep track of the indexes in the array and marrying them to a specific callback… doing that would make the code surrounding the callbacks pretty complex.
I did do a kind of hack up job of making all of the callbacks declared function pointers outside of structures and functions. This gave me the ability to get the code written to handle them. So that aspect is all done. making changes from this point on however the user_data issue get handled hopefully won’t end up being a complete rewrite of my code.
Because of the dynamic nature of this binding and nothing really being hard coded there needed to be a way to make it easier to develop for. If using a Python IDE like PyCharm or VSCode all of the code completion and type hinting will work properly. Makes it easier having this.
I have not changed the API from being as close as possible to the C API. I am able to duplicate the MicroPython API if that is what is done. It will increase the code footprint by a large amount and it will also slow things down quite a bit. This is due to the lookups needing to be done while the code is running. It’s not something that can be compiled ahead of time.
I would have to check into it by I may be able to compile the Python code portion into a C extension using Cython. I am not using any metaclasses so I should be able to. This will speed up code execution by up to 200% if it can be done.