The gfx-hat sample contrast-scanner.py gives the following error when launched with ‘python’:
Traceback (most recent call last):
File “contrast-scanner.py”, line 60, in
lcd.contrast(0)
AttributeError: ‘module’ object has no attribute ‘contrast’
When launched
with ‘python3’ gives the following error:
Traceback (most recent call last):
File “contrast-scanner.py”, line 21, in
font = ImageFont.truetype(fonts.Bitocra13Full, 13)
AttributeError: module ‘gfxhat.fonts’ has no attribute ‘Bitocra13Full’
So when you use the curl installer it seems to install a seriously old version of some of the files. That’s something one of the Pimoroni crew (@gadgetoid ?) would have to fix.
In the meantime, you can get the latest files from GitHub directly (git clone https://github.com/pimoroni/gfx-hat.git), but you’ll either need to run the scripts from inside the library folder or add it to your path.
EDIT:
Btw I do not know where the GFX library is installed on my Pi, can anyone tell me ?
I forgot that the modules don’t go in there, just the example. They go into /usr/local/lib/python2.7/dist-packages/gfxhat, or python3.7 for 3.
It looks like the gfxhat library that is installed is out of date.
I replaced the files under:
/usr/local/lib/python2.7/dist-packages/gfxhat
and
/usr/local/lib/python3.7/dist-packages/gfxhat
with the files here:
and then the contrast example works.
This is not the right way to fix it as I think pip must maintain hashes, but I don’t know pip or python yet.
Here’s my solution, for python 3: cd /usr/local/lib/python3.7/dist-packages sudo mkdir old sudo mv gfxhat old sudo git clone https://github.com/pimoroni/gfx-hat sudo cp -r gfx-hat/library/gfxhat gfxhat
…now the examples should work.