Inky What Hello World issue with Image.new no attribute 'WIDTH'

Hi!

Grabbed a inky phat the other today and got it working for what I wanted, but it needed something bigger, so grabbed an Inky What Red.

Following the getting started guide has the same issues as the phat guide with needing to separately install the fonts, but I’ve a new issue with the hello world example:

from inky.auto import auto
from PIL import Image, ImageFont, ImageDraw

inky_display = auto()
inky_display.set_border(inky_display.WHITE)

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
draw = ImageDraw.Draw(img)

executing this generates the following error:

Traceback (most recent call last):
  File "/home/kelly/inky/code/test.py", line 7, in <module>
    img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
                          ^^^^^^^^^^^^^^^^^^
AttributeError: 'Inky' object has no attribute 'WIDTH'

Any clues as to what to do?

In that usual trend of posting a question on a forum after you bashing your head on something for you to then figure it out… I guess it’s useful for other searchers.

If you change the case of HEIGHT and WIDTH to height and width it works. This is a difference from the phat and wrong in the getting started guide!

Looking at one of the examples, it appears you can also use inky_display.resolution to replace both of them:

img = Image.new("P", (inky_display.height, inky_display.width))

OR

img = Image.new("P", inky_display.resolution)

1 Like