point changes and logo options added

This commit is contained in:
Neythen
2021-10-18 18:38:24 +01:00
parent 1326007787
commit a1c9c3ba8f
14 changed files with 210 additions and 125 deletions

View File

@@ -1 +1 @@
{"speed": "medium", "animation": "continuous", "title": true, "pause": "", "images": ["open.gif", "close.gif"]} {"speed": "medium", "animation": "down", "title": true, "pause": "2", "images": ["open.gif", "close.gif"]}

View File

@@ -1 +1 @@
{"feature": "Stocks", "speed": "medium", "animation": "traditional", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.42, "24hr_change": -3.963839231643678}, "BTC,USD": {"current": 49343, "24hr_change": 0.902025932223419}, "ETH,BTC": {"current": 0.06930671, "24hr_change": -1.7367682270496585}, "ADA,GBP": {"current": 1.62, "24hr_change": -3.549646457710461}}} {"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NEO,USD": {"current": 43.42, "24hr_change": -3.963839231643678}, "BTC,USD": {"current": 49343, "24hr_change": 0.902025932223419}, "ETH,BTC": {"current": 0.06930671, "24hr_change": -1.7367682270496585}, "ADA,GBP": {"current": 1.62, "24hr_change": -3.549646457710461}}}

View File

@@ -1 +1 @@
["Stocks", "Crypto", "Forex"] ["Forex Prof", "Stocks Prof", "Crypto Prof"]

View File

@@ -1 +1 @@
{"feature": "Stocks", "speed": "fast", "animation": "down", "percent": false, "point": true, "logos": true, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9471, "24hr_change": 0.0029000000000001247}, "CAD,USD": {"current": 1.271, "24hr_change": 0.0033999999999998476}}} {"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"NZD,GBP": {"current": 1.9471, "24hr_change": 0.0029000000000001247}, "CAD,USD": {"current": 1.271, "24hr_change": 0.0033999999999998476}}}

View File

@@ -1 +1 @@
{"speed": "medium", "animation": "traditional", "title": true, "pause": "3", "images": ["XOM.png", "ZBRA.png"]} {"speed": "slow", "animation": "down", "title": true, "pause": "/", "images": ["XOM.png", "ZBRA.png"]}

View File

@@ -1 +1 @@
{"feature": "Stocks", "speed": "slow", "animation": "down", "percent": true, "point": false, "logos": true, "chart": false, "title": true, "symbols": {"MSFT": {"current": 282.63, "opening": 287.28}, "GOOG": {"current": 2665.2, "opening": 2713.99}}} {"feature": "Stocks", "speed": "medium", "animation": "down", "percent": false, "point": true, "logos": false, "chart": false, "title": true, "symbols": {"MSFT": {"current": 282.63, "opening": 287.28}, "GOOG": {"current": 2665.2, "opening": 2713.99}}}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@@ -311,7 +311,7 @@ class StockTicker():
def set_delay(self,speed): def set_delay(self,speed):
if speed.lower() == 'slow': if speed.lower() == 'slow':
self.delay = 0.04 self.delay = 0.03
elif speed.lower() == 'medium': elif speed.lower() == 'medium':
self.delay = 0.02 self.delay = 0.02
elif speed.lower() == 'fast': elif speed.lower() == 'fast':
@@ -886,25 +886,34 @@ class StockTicker():
ticker, base = cb.split(',') ticker, base = cb.split(',')
current = coin_info[cb]["current"] current = coin_info[cb]["current"]
change = coin_info[cb]["24hr_change"] change = coin_info[cb]["24hr_change"]
if all_crypto_settings["point"]:
# convert percent to points
change = change/100 * current
current = '%.2f' % current current = '%.2f' % current
arrow, change = self.getArrow(change) arrow, change = self.getArrow(change)
change = '%.2f' % change
midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT if all_crypto_settings["point"]:
# convert percent to points
try: change = change/100 * current
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto') change = '%.2f' % change
else:
change = '%.2f' % change +'%'
logo = Image.open(os.path.join(logos_path, ticker + '.png')) midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
stitchedStock = self.stitchImage([logo,midFrame])
except: if all_crypto_settings['logos']:
try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame])
except:
stitchedStock = midFrame
else:
stitchedStock = midFrame stitchedStock = midFrame
image_list.append(stitchedStock) image_list.append(stitchedStock)
image_list.append(self.blank) image_list.append(self.blank)
@@ -943,25 +952,34 @@ class StockTicker():
current = coin_info[cb]["current"] current = coin_info[cb]["current"]
change = coin_info[cb]["24hr_change"] change = coin_info[cb]["24hr_change"]
arrow, change = self.getArrow(change, professional=True)
if all_crypto_settings["point"]: if all_crypto_settings["point"]:
# convert percent to points # convert percent to points
change = change/100 * current change = change/100 * current
change = '%.2f' % change
else:
change = '%.2f' % change +'%'
current = '%.2f' % current current = '%.2f' % current
arrow, change = self.getArrow(change, professional=True)
change = '%.2f' % change
midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT midFrame = self.textToImageProf(ticker + '(' + base + ')', current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
if all_crypto_settings['logos']:
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
logo = Image.open(os.path.join(logos_path, ticker + '.png')) logo = Image.open(os.path.join(logos_path, ticker + '.png'))
w,h = logo.size w,h = logo.size
logo=logo.resize((int(w/2), int(h/2))) logo=logo.resize((int(w/2), int(h/2)))
stitchedStock = self.stitchImage([logo,midFrame]) stitchedStock = self.stitchImage([logo,midFrame])
except: except:
stitchedStock = midFrame
else:
stitchedStock = midFrame stitchedStock = midFrame
image_list.append(stitchedStock) image_list.append(stitchedStock)
@@ -995,30 +1013,43 @@ class StockTicker():
current = forex_settings[sb]['current'] current = forex_settings[sb]['current']
change = forex_settings[sb]['24hr_change'] change = forex_settings[sb]['24hr_change']
current = '%.3f' % current
arrow, change = self.getArrow(change) arrow, change = self.getArrow(change)
change = '%.6f' % change
midFrame = self.textToImage(symbol+ '(' + base + ')', current, change, arrow) #IMAGE THE TEXT if all_forex_settings["percent"]:
# convert percent to points
try: change = change/current * 100
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies')
logo = Image.open(os.path.join(logos_path, symbol.lower() + '.png'))
bse = Image.open(os.path.join(logos_path, base.lower() + '.png'))
new_im = Image.new('RGB', (32, 32)) change = '%.2f' % change + '%'
else:
change = '%.6f' % change
new_im.paste(bse, (0,10), bse.convert('RGBA'))
new_im.paste(logo, (10,0), logo.convert('RGBA')) current = '%.3f' % current
stitchedStock = self.stitchImage([new_im, midFrame])
image_list.append(new_im)
except Exception as e:
print(e)
midFrame = self.textToImage(symbol+ '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
if all_forex_settings['logos']:
try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies')
logo = Image.open(os.path.join(logos_path, symbol.lower() + '.png'))
bse = Image.open(os.path.join(logos_path, base.lower() + '.png'))
new_im = Image.new('RGB', (32, 32))
new_im.paste(bse, (0,10), bse.convert('RGBA'))
new_im.paste(logo, (10,0), logo.convert('RGBA'))
stitchedStock = self.stitchImage([new_im, midFrame])
image_list.append(new_im)
except Exception as e:
print(e)
image_list.append(midFrame) image_list.append(midFrame)
image_list.append(self.blank) image_list.append(self.blank)
finalDisplayImage = self.stitchImage(image_list) finalDisplayImage = self.stitchImage(image_list)
@@ -1051,35 +1082,44 @@ class StockTicker():
current = forex_settings[sb]['current'] current = forex_settings[sb]['current']
change = forex_settings[sb]['24hr_change'] change = forex_settings[sb]['24hr_change']
current = '%.3f' % current
arrow, change = self.getArrow(change, professional = True) arrow, change = self.getArrow(change, professional = True)
change = '%.6f' % change
if all_forex_settings["percent"]:
# convert percent to points
change = change/current * 100
change = '%.2f' % change + '%'
else:
change = '%.6f' % change
current = '%.3f' % current
midFrame = self.textToImageProf(symbol + '(' + base + ')', current, change, arrow, font = ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT midFrame = self.textToImageProf(symbol + '(' + base + ')', current, change, arrow, font = ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
if all_forex_settings['logos']:
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'currencies')
logo = Image.open(os.path.join(logos_path, symbol.lower() + '.png')) logo = Image.open(os.path.join(logos_path, symbol.lower() + '.png'))
bse = Image.open(os.path.join(logos_path, base.lower() + '.png')) bse = Image.open(os.path.join(logos_path, base.lower() + '.png'))
new_im = Image.new('RGB', (32, 32))
new_im.paste(bse, (0,10), bse.convert('RGBA'))
new_im.paste(logo, (10,0), logo.convert('RGBA'))
width, height = new_im.size
new_im = new_im.resize((int(width/2), int(height/2))) new_im = Image.new('RGB', (32, 32))
new_im.paste(bse, (0,10), bse.convert('RGBA'))
new_im.paste(logo, (10,0), logo.convert('RGBA'))
width, height = new_im.size
new_im = new_im.resize((int(width/2), int(height/2)))
stitchedStock = self.stitchImage([new_im, midFrame])
image_list.append(new_im)
stitchedStock = self.stitchImage([new_im, midFrame]) except Exception as e:
image_list.append(new_im) print(e)
except Exception as e:
print(e)
image_list.append(midFrame) image_list.append(midFrame)
image_list.append(self.blank) image_list.append(self.blank)
@@ -1116,20 +1156,31 @@ class StockTicker():
change = float(info['current'])-float(info['opening']) #TEXT change = float(info['current'])-float(info['opening']) #TEXT
ticker = symbol #TEXT ticker = symbol #TEXT
current = '%.2f' % float(info['current']) #TEXT
arrow, change = self.getArrow(change) arrow, change = self.getArrow(change)
change = '%.2f' % change
if all_stocks_settings["percent"]:
change = change/float(info['current']) * 100
change = '%.2f' % change + '%'
else:
change = '%.2f' % change
current = '%.2f' % float(info['current']) #TEXT
midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT midFrame = self.textToImage(ticker, current, change, arrow) #IMAGE THE TEXT
if all_stocks_settings['logos']:
try: try:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks') logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = Image.open(os.path.join(logos_path, ticker + '.png')) logo = Image.open(os.path.join(logos_path, ticker + '.png'))
stitchedStock = self.stitchImage([logo,midFrame]) stitchedStock = self.stitchImage([logo,midFrame])
except: except:
stitchedStock = midFrame
else:
stitchedStock = midFrame stitchedStock = midFrame
image_list.append(stitchedStock) image_list.append(stitchedStock)
@@ -1169,32 +1220,42 @@ class StockTicker():
change = float(info['current'])-float(info['opening']) #TEXT change = float(info['current'])-float(info['opening']) #TEXT
ticker = symbol #TEXT ticker = symbol #TEXT
current = '%.2f' % float(info['current']) #TEXT
arrow, change = self.getArrow(change, professional=True) arrow, change = self.getArrow(change, professional=True)
change = '%.2f' % change
if all_stocks_settings["percent"]:
# convert percent to points
change = change/float(info['current'])* 100
change = '%.2f' % change + '%'
else:
change = '%.2f' % change
current = '%.2f' % float(info['current']) #TEXT
midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT midFrame = self.textToImageProf(ticker, current, change, arrow, font=ImageFont.load("./fonts/6x10.pil")) #IMAGE THE TEXT
if all_stocks_settings['logos']:
try:
try: #load the tiny logo
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_stocks')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
except: # load the big logo and scale it
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
# half the size of the logo
width, height = logo.size
logo = logo.resize((int(width/2), int(height/2)))
stitchedStock = self.stitchImage([logo,midFrame])
except Exception as e:
try: stitchedStock = midFrame
try: #load the tiny logo else:
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'tiny_stocks')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
except: # load the big logo and scale it
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'stocks')
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
# half the size of the logo
width, height = logo.size
logo = logo.resize((int(width/2), int(height/2)))
stitchedStock = self.stitchImage([logo,midFrame])
except Exception as e:
stitchedStock = midFrame stitchedStock = midFrame
image_list.append(stitchedStock) image_list.append(stitchedStock)
@@ -2152,20 +2213,22 @@ class StockTicker():
def getUserImages(self): def getUserImages(self):
title_img = self.openImage('feature_titles/images.png')
f = open('csv/image_settings.json', 'r') f = open('csv/image_settings.json', 'r')
all_settings = json.load(f) all_settings = json.load(f)
f.close() f.close()
if all_settings['title']:
imgs = [title_img] imgs = []
else: for ind,image in enumerate(all_settings['images']):
imgs = []
for image in all_settings['images']:
img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image)) img = self.openImage(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), image))
imgs.append(img)
if all_settings['title'] and ind == 0:
title_img = self.openImage('feature_titles/images.png')
imgs.append(self.stitchImage([title_img, img]))
else:
imgs.append(img)
return imgs return imgs
@@ -2175,15 +2238,30 @@ class StockTicker():
all_settings = json.load(f) all_settings = json.load(f)
f.close() f.close()
if all_settings['title']: GIFs = []
title_img = self.openImage('feature_titles/gifs.png')
GIFs = [title_img]
else:
GIFs = []
for f in all_settings['images']: for ind,fle in enumerate(all_settings['images']):
GIF = Image.open(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), f))
GIFs.append(GIF)
GIF = Image.open(os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'user_uploads'), fle))
if ind == 0 and all_settings['title']:
frames = []
title_img = self.openImage('feature_titles/gifs.png')
for i, frame in enumerate(ImageSequence.Iterator(GIF)):
f = self.stitchImage([title_img, frame])
frames.append(f)
frames[0].save('./display_images/working_gif.gif', save_all=True, append_images=frames[1:], loop=0, optimize = False)
GIF = Image.open('./display_images/working_gif.gif')
GIFs.append(GIF)
else:
GIFs.append(GIF)
#below code stitches title and GIF together #below code stitches title and GIF together
''' '''

View File

@@ -1988,8 +1988,11 @@
id="inputText12" id="inputText12"
class="form-control pause-select" class="form-control pause-select"
aria-describedby="TextHelpInline" aria-describedby="TextHelpInline"
value={{image_settings.pause}}
/> />
</div> </div>
<!--
<div class="col-auto"> <div class="col-auto">
<input <input
class="form-check-input" class="form-check-input"
@@ -1999,6 +2002,7 @@
checked checked
/> />
</div> </div>
-->
</div> </div>
<div class="row g-3 align-items-center mt-3"> <div class="row g-3 align-items-center mt-3">
@@ -2140,8 +2144,10 @@
id="inputText112" id="inputText112"
class="form-control pause-select" class="form-control pause-select"
aria-describedby="TextHelpInline" aria-describedby="TextHelpInline"
value={{GIF_settings.pause}}
/> />
</div> </div>
<!--
<div class="col-auto"> <div class="col-auto">
<input <input
class="form-check-input" class="form-check-input"
@@ -2151,6 +2157,7 @@
checked checked
/> />
</div> </div>
-->
</div> </div>
<div class="row g-3 align-items-center mt-3"> <div class="row g-3 align-items-center mt-3">