bugfix: optional parameters

This commit is contained in:
waltem01 2024-02-15 09:36:28 +01:00
parent 0ff0f2ecad
commit 21416fd55a

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from deps.samplebase import SampleBase from deps.samplebase import SampleBase
from rgbmatrix import graphics from rgbmatrix import graphics
from typing import Optional
from PIL import Image from PIL import Image
import requests import requests
@ -294,7 +295,7 @@ class Matrix(SampleBase):
self.image = Image.open(requests.get(url, stream=True).raw) self.image = Image.open(requests.get(url, stream=True).raw)
# display image at position with dimensions in current color # display image at position with dimensions in current color
def display_image(self, x: int, y: int, w: int|None = None, h: int|None = None): def display_image(self, x: int, y: int, w: Optional[int] = None, h: Optional[int] = None):
# resize image to specified or max size # resize image to specified or max size
self.image.resize((w or self.matrix.width, h or self.matrix.height), Image.ANTIALIAS) self.image.resize((w or self.matrix.width, h or self.matrix.height), Image.ANTIALIAS)
# set image at position # set image at position