Gfx-hat contrast problems

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’

Any Idea?

Hi
Same problem here, I juste bought a GFX-HAT and I installed the library on my RPi using:
curl https://get.pimoroni.com/gfxhat | bash

All the examples works except the contrast-scanner.py which gives me the same error as @ezio.soma .

If you look here, the contrast attribute is defined so is there is something wrong with the library installation ?

Btw I do not know where the GFX library is installed on my Pi, can anyone tell me ?

Thanks in advance.
M.

Hi
Are we the only ones with this problem ?
M.

I’ll try to remember to check mine when I get home.

The Python3 bug seems to be with an improper font name in the script. I’m not sure what the issue with the Python2 version is.

Btw I do not know where the GFX library is installed on my Pi, can anyone tell me ?

If I remember right it should be in /home/Pi/Pimoroni.

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.

Hello, I’m not sure to have well understood. The steps are:

  1. git clone https://github.com/pimoroni/gfx-hat.git
  2. go to … gfx-hat/gfx-hat/library
  3. sudo pyhton setup.py
  4. cd …/examples
  5. python contrast-scanner.py

I’ve tryed and got the Same error. I suppose that it is not correct. Could you specify the steps that I have to execute?
Many thanks, Ezio