From 9bd47e7ad14a850b01d9c6aebcbe16ffb08c0dc0 Mon Sep 17 00:00:00 2001 From: mrwunderbar666 Date: Mon, 31 Jul 2017 10:06:08 +0800 Subject: [PATCH] Fixed pathing to graphics issue --- examples/weather.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/weather.py b/examples/weather.py index e1a728a..dfbbcfd 100644 --- a/examples/weather.py +++ b/examples/weather.py @@ -14,14 +14,18 @@ from __future__ import print_function -from datetime import date from datetime import datetime import calendar import urllib, json import time +import os from escpos.printer import Usb +""" Setting up the main pathing """ +this_dir, this_filename = os.path.split(__file__) +GRAPHICS_PATH = os.path.join(this_dir, "graphics/climacons/") + # Adapt to your needs printer = Usb(0x0416, 0x5011, profile="POS-5890") @@ -34,7 +38,7 @@ LONG = "114.189945" # Your Location def forecast_icon(idx): icon = data['daily']['data'][idx]['icon'] - image = "/graphics/climacons/" + icon + ".png" + image = GRAPHICS_PATH + icon + ".png" return image @@ -68,7 +72,7 @@ def forecast(idx): def icon(): icon = data['currently']['icon'] - image = "/graphics/" + icon + ".png" + image = GRAPHICS_PATH + icon + ".png" return image