electronstudio / raylib-python-cffi

Python CFFI bindings for Raylib
http://electronstudio.github.io/raylib-python-cffi
Eclipse Public License 2.0
152 stars 29 forks source link

Unresolved reference `Color`, Pycharm issue #88

Closed sDos280 closed 2 years ago

sDos280 commented 2 years ago

while trying to use the Quickstart example in pycharm I Noticed that the IDE says that there is an error "unresolved reference 'WHITE'" and the error "unresolved reference 'VIOLET'". but when I tried to run the example it work perfectly. Is there a reason for this error?

example:

from pyray import *
init_window(800, 450, "Hello")
while not window_should_close():
    begin_drawing()
    clear_background(WHITE)
    draw_text("Hello world", 190, 200, 20, VIOLET)
    end_drawing()
close_window()

error image: image

sDos280 commented 2 years ago

ok, I think I understand why this is happening, that is just the way the library work. in any case thanks 🙃

electronstudio commented 2 years ago

it's because we are using .pyi files to get PyCharm to do autocomplete, but the Colors were not listed in them.

sDos280 commented 2 years ago

ok, so why did this run with no problem? how did the interpreter know what WHITE/VIOLET means?

also, I have this problem too (that isn't really an issue more like a question) image I know that the KEY_RIGHT is defied in the .pyi file but it is in the KeyboardKey class, so how does python know to pick/use that?

electronstudio commented 2 years ago

I think pyray.KEY_RIGHT is provided by CFFI. Then we later generated proper Python Enums from what CFFI provided, so we added pyray.KeyboardKey.KEY_RIGHT. But we allowed pyray. KEY_RIGHT to remain for backwards compatibility.

sDos280 commented 2 years ago

That makes sense, thanks.