GFX Hat examples don't load

Hi. I’ve just got a pi 4 with the gfx hat.

I’ve installed the gfx hat as per the installation instructions.

I’ve copied the “hello world” example into a python file named “Display.py”, but when I run it, I get the following errors; and I wondered if anyone could help?

pi@buttons:~ $ python3 Display.py
hello-world.py
This basic example prints the text “Hello World” in the middle of the LCD
Press any button to see its corresponding LED toggle on/off.
Press Ctrl+C to exit.

/home/pi/Display.py:27: DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead.
w, h = font.getsize(text)
Traceback (most recent call last):
File “/home/pi/Display.py”, line 51, in
touch.on(x, handler)
File “/usr/local/lib/python3.9/dist-packages/gfxhat/touch.py”, line 119, in on
register(handler)
File “/usr/local/lib/python3.9/dist-packages/gfxhat/touch.py”, line 114, in register
_cap1166.on(channel=button, event=‘press’, handler=handler)
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 386, in on
self.start_watching()
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 400, in start_watching
self.async_poll.start()
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 208, in start
if self.isAlive() == False:
AttributeError: ‘AsyncWorker’ object has no attribute ‘isAlive’
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 409, in stop_watching
self.async_poll.stop()
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 213, in stop
if self.isAlive() == True:
AttributeError: ‘AsyncWorker’ object has no attribute ‘isAlive’
Exception ignored in: <function Cap1xxx.del at 0x7fb832e550>
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 522, in del
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 409, in stop_watching
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 213, in stop
AttributeError: ‘AsyncWorker’ object has no attribute ‘isAlive’
pi@buttons:~ $

Try running sudo pip3 install gfxhat and try the examples again.

I am experiencing the same error messages I have tried the " sudo pip3 install gfxhat" suggestion and no change. although the product info says all PIs , could the PI zero w i am trying to use it with be the problem?

if you are experiencing this problem . try “pip3 install --upgrade capxxx” and “pip3 install --upgrade sn3218” the files referred ot in the curl access load older versions of these libraries , it might be worth up dating the curl files target to the newer libraries?

Glad to hear that you figured it out, and thanks for posting your solution!

If you have the time, please can you open an issue on the GFX HAT Github repo to get this on our software folks’ radar?

Hi, I’ve tried all of the things suggested in this thread, but I’m still having issues. This is what I’m getting from my Pi:

pi@buttons:~/Pimoroni/gfxhat/examples $ ~pi@buttons:~/Pimoroni/gfxhat/examples $ pi@buttons:~/Pimoroni/gfxhat/examples $ python3 hello-world.py
hello-world.py

This basic example prints the text “Hello World” in the middle of the LCD

Press any button to see its corresponding LED toggle on/off.

Press Ctrl+C to exit.

/home/pi/Pimoroni/gfxhat/examples/hello-world.py:31: DeprecationWarning: getsize is deprecated and will be removed in Pillow 10 (2023-07-01). Use getbbox or getlength instead.
w, h = font.getsize(text)
Traceback (most recent call last):
File “/home/pi/Pimoroni/gfxhat/examples/hello-world.py”, line 55, in
touch.on(x, handler)
File “/usr/local/lib/python3.9/dist-packages/gfxhat/touch.py”, line 119, in on
register(handler)
File “/usr/local/lib/python3.9/dist-packages/gfxhat/touch.py”, line 114, in register
_cap1166.on(channel=button, event=‘press’, handler=handler)
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 386, in on
self.start_watching()
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 400, in start_watching
self.async_poll.start()
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 208, in start
if self.isAlive() == False:
AttributeError: ‘AsyncWorker’ object has no attribute ‘isAlive’
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 409, in stop_watching
self.async_poll.stop()
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 213, in stop
if self.isAlive() == True:
AttributeError: ‘AsyncWorker’ object has no attribute ‘isAlive’
Exception ignored in: <function Cap1xxx.del at 0x7fa77ff550>
Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 522, in del
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 409, in stop_watching
File “/usr/lib/python3/dist-packages/cap1xxx.py”, line 213, in stop
AttributeError: ‘AsyncWorker’ object has no attribute ‘isAlive’
[200~Traceback (most recent call last):
-bash: pi@buttons:~/Pimoroni/gfxhat/examples: No such file or directory
-bash: hello-world.py: command not found
-bash: This: command not found
-bash: Press: command not found
-bash: Press: command not found
-bash: syntax error near unexpected token (' -bash: syntax error near unexpected token (’
-bash: syntax error near unexpected token most' -bash: syntax error near unexpected token newline’
-bash: syntax error near unexpected token x,' -bash: File: command not found -bash: syntax error near unexpected token handler’
-bash: File: command not found
-bash: syntax error near unexpected token channel=button,' -bash: File: command not found -bash: syntax error near unexpected token File’
-bash: syntax error near unexpected token File' -bash: syntax error near unexpected token ==’
-bash: AttributeError:: command not found
-bash: Error: command not found
"/usr/lib/python3/dist-packages/cap1xxx.py"most’ne’

Although I do get some flashing lights before it completely fails.