Skip to content

Adding an URL-based image path kwarg to PyPortal #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions adafruit_pyportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ class PyPortal:
:param caption_position: The position of your caption on the display as an (x, y) tuple.
Defaults to ``None``.
:param caption_color: The color of your caption. Must be a hex value, e.g. ``0x808000``.
:param image_url_path: The HTTP traversal path for a background image to display.
Defaults to ``None``.
:param debug: Turn on debug print outs. Defaults to False.

"""
Expand All @@ -151,7 +153,7 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None,
text_wrap=False, text_maxlen=0, text_transform=None,
image_json_path=None, image_resize=None, image_position=None,
caption_text=None, caption_font=None, caption_position=None,
caption_color=0x808080,
caption_color=0x808080, image_url_path=None,
success_callback=None, debug=False):

self._debug = debug
Expand Down Expand Up @@ -317,9 +319,10 @@ def __init__(self, *, url=None, headers=None, json_path=None, regexp_path=None,
self._text = None

self._image_json_path = image_json_path
self._image_url_path = image_url_path
self._image_resize = image_resize
self._image_position = image_position
if image_json_path:
if image_json_path or image_url_path:
if self._debug:
print("Init image path")
if not self._image_position:
Expand Down Expand Up @@ -690,6 +693,9 @@ def fetch(self):
if self._regexp_path:
import re

if self._image_url_path:
image_url = self._image_url_path

# extract desired text/values from json
if self._json_path:
for path in self._json_path:
Expand Down