kdschlosser / lv_cpython

CPython bindings to LVGL
Other
16 stars 4 forks source link

How to make it work to test #11

Open moroslantia opened 1 year ago

moroslantia commented 1 year ago

I would like to give it a try but somehow i'm lost how to make the dev branch work on my pc. Can you provide some instructions to follow?

Thank you a lot in advance

kdschlosser commented 1 year ago

What OS are you running?

moroslantia commented 1 year ago

I've the choice of Windows 11, Linux Debian 12, Self managed Linux (latest buildroot) for testing. Targeted production environment is the self managed linux without X Server.

kdschlosser commented 1 year ago

well for Windows you will need to have Visual Studio installed along with all of the C components and a Windows SDK. Optionally you can install the Visual Studio Build Tools if you don't want to install all of Visual Studio. Build Tools will only install the bits needed to compile from a command line which is really what we need.

Once you have that done then clone the repo, go into the directory for the repo and type in

pip install .

don't forget the dot on the end it needs to be there.

moroslantia commented 1 year ago

This worked well - seems ...

Installing collected packages: lvgl
Attempting uninstall: lvgl
Found existing installation: lvgl 0.1.0
Uninstalling lvgl-0.1.0:
Successfully uninstalled lvgl-0.1.0
Successfully installed lvgl-0.2.0b0

However:

python3.10.exe .\btn_1.py Traceback (most recent call last):

File "C:\Daten\repository\github\lv_cpython\examples\btn_1.py", line 11, in

lv.init()

AttributeError: module 'lvgl' has no attribute 'init'

What did i miss ?

kdschlosser commented 1 year ago

I have not finished with the examples and they still need to be updated. This is what you need to do to get them to work.

You have to edit each example and change the lines at the top that read

import os
import sys

base_path = os.path.dirname(__file__)
sys.path.insert(0, os.path.abspath(os.path.join(base_path, '..')))

import lvgl as lv

import time

lv.init()

to this

import os
import sys
import time

try:
    import lvgl as lv
    lv.init()
except (ImportError, AttributeError):
    base_path = os.path.dirname(__file__)
    sys.path.insert(0, os.path.abspath(os.path.join(base_path, '..')))

    import lvgl as lv
    lv.init()

That should fix the issue. If it doesn't let me know as there is something screwy the install portion of the program is doing that is causing the problem and I will need to correct it.

kdschlosser commented 1 year ago

also are you running the examples from command line or are you running them from an IDE like PyCharm? If you are running them from an IDE it might be a little more complicated to correct because of how an IDE messes with the path when ti launches Python.

moroslantia commented 1 year ago

I have not finished with the examples and they still need to be updated. This is what you need to do to get them to work.

You have to edit each example and change the lines at the top that read

import os
import sys

base_path = os.path.dirname(__file__)
sys.path.insert(0, os.path.abspath(os.path.join(base_path, '..')))

import lvgl as lv

import time

lv.init()

to this

import os
import sys
import time

try:
    import lvgl as lv
    lv.init()
except (ImportError, AttributeError):
    base_path = os.path.dirname(__file__)
    sys.path.insert(0, os.path.abspath(os.path.join(base_path, '..')))

    import lvgl as lv
    lv.init()

That should fix the issue. If it doesn't let me know as there is something screwy the install portion of the program is doing that is causing the problem and I will need to correct it.

With this, some examples start to work. Thank you for your help.

On others I get exceptions and errors and i don't want do bother you when you are in the middle of the work, exept you want me to report what i see already.

kdschlosser commented 1 year ago

It's in the develop branch for a reason. I am working on ironing out problems the biggest one is a memory leak and I have solved that but broke 10 other things in the process. So I need to make some code changes to fix the broken things.

moroslantia commented 1 year ago

It's in the develop branch for a reason. I am working on ironing out problems the biggest one is a memory leak and I have solved that but broke 10 other things in the process. So I need to make some code changes to fix the broken things.

Sure. I apologize if I have upset you.

kdschlosser commented 1 year ago

you didn't upset me at all. I know there are issues with it and I am tearing my hair out with getting it to work. I fix one thing and it breaks something else. The problem is the horribly cryptic error messages ctypes throws and there is no information as to what is causing it. I m using the visual studio debugger to help out but and that only points me to the location where the error is occurring not really what is causing it. It doesn't show the data path through the program so it's not as helpful as it could be.

pmp-p commented 10 months ago

you could also test on browser directly without installing anything : eg from a gist https://pygame-web.github.io/showroom/pypad_git.html#https://gist.githubusercontent.com/pmp-p/2860ea78375a1932702ab2cf366ab198/raw/68b345dcb0ca4ac2325ff69506ae86910639468f/lvgl_gist_test.py or with https://pypi.org/project/pygbag from any python >3.9 for local tests with some assets. ( nothing is executed natively on the pc all is running on WebAssembly in the browser both python and lvgl )