point changes and logo options added
This commit is contained in:
parent
1326007787
commit
a1c9c3ba8f
@ -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"]}
|
@ -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}}}
|
@ -1 +1 @@
|
||||
["Stocks", "Crypto", "Forex"]
|
||||
["Forex Prof", "Stocks Prof", "Crypto Prof"]
|
@ -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}}}
|
@ -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"]}
|
@ -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.
BIN
display_images/working_gif.gif
Normal file
BIN
display_images/working_gif.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
316
stockTicker.py
316
stockTicker.py
@ -311,7 +311,7 @@ class StockTicker():
|
||||
|
||||
def set_delay(self,speed):
|
||||
if speed.lower() == 'slow':
|
||||
self.delay = 0.04
|
||||
self.delay = 0.03
|
||||
elif speed.lower() == 'medium':
|
||||
self.delay = 0.02
|
||||
elif speed.lower() == 'fast':
|
||||
@ -886,25 +886,34 @@ class StockTicker():
|
||||
ticker, base = cb.split(',')
|
||||
current = coin_info[cb]["current"]
|
||||
change = coin_info[cb]["24hr_change"]
|
||||
|
||||
if all_crypto_settings["point"]:
|
||||
# convert percent to points
|
||||
change = change/100 * current
|
||||
|
||||
current = '%.2f' % current
|
||||
|
||||
arrow, change = self.getArrow(change)
|
||||
change = '%.2f' % change
|
||||
midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
|
||||
|
||||
try:
|
||||
logos_path = os.path.join(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'logos'), 'crypto')
|
||||
|
||||
if all_crypto_settings["point"]:
|
||||
# convert percent to points
|
||||
change = change/100 * current
|
||||
change = '%.2f' % change
|
||||
else:
|
||||
change = '%.2f' % change +'%'
|
||||
|
||||
|
||||
|
||||
|
||||
logo = Image.open(os.path.join(logos_path, ticker + '.png'))
|
||||
stitchedStock = self.stitchImage([logo,midFrame])
|
||||
except:
|
||||
|
||||
midFrame = self.textToImage(ticker + '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
|
||||
|
||||
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
|
||||
|
||||
image_list.append(stitchedStock)
|
||||
|
||||
image_list.append(self.blank)
|
||||
@ -943,25 +952,34 @@ class StockTicker():
|
||||
current = coin_info[cb]["current"]
|
||||
change = coin_info[cb]["24hr_change"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
arrow, change = self.getArrow(change, professional=True)
|
||||
|
||||
if all_crypto_settings["point"]:
|
||||
# convert percent to points
|
||||
change = change/100 * current
|
||||
|
||||
change = '%.2f' % change
|
||||
else:
|
||||
|
||||
change = '%.2f' % change +'%'
|
||||
|
||||
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
|
||||
|
||||
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'))
|
||||
|
||||
w,h = logo.size
|
||||
logo=logo.resize((int(w/2), int(h/2)))
|
||||
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'))
|
||||
|
||||
w,h = logo.size
|
||||
logo=logo.resize((int(w/2), int(h/2)))
|
||||
stitchedStock = self.stitchImage([logo,midFrame])
|
||||
except:
|
||||
|
||||
stitchedStock = midFrame
|
||||
else:
|
||||
stitchedStock = midFrame
|
||||
image_list.append(stitchedStock)
|
||||
|
||||
@ -995,30 +1013,43 @@ class StockTicker():
|
||||
current = forex_settings[sb]['current']
|
||||
change = forex_settings[sb]['24hr_change']
|
||||
|
||||
current = '%.3f' % current
|
||||
|
||||
|
||||
|
||||
arrow, change = self.getArrow(change)
|
||||
change = '%.6f' % change
|
||||
midFrame = self.textToImage(symbol+ '(' + base + ')', current, change, arrow) #IMAGE THE TEXT
|
||||
|
||||
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'))
|
||||
|
||||
if all_forex_settings["percent"]:
|
||||
# convert percent to points
|
||||
change = change/current * 100
|
||||
|
||||
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)
|
||||
change = '%.2f' % change + '%'
|
||||
else:
|
||||
change = '%.6f' % change
|
||||
|
||||
current = '%.3f' % current
|
||||
|
||||
|
||||
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(self.blank)
|
||||
finalDisplayImage = self.stitchImage(image_list)
|
||||
@ -1051,35 +1082,44 @@ class StockTicker():
|
||||
current = forex_settings[sb]['current']
|
||||
change = forex_settings[sb]['24hr_change']
|
||||
|
||||
current = '%.3f' % current
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
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'))
|
||||
width, height = new_im.size
|
||||
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 = 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])
|
||||
image_list.append(new_im)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
image_list.append(midFrame)
|
||||
|
||||
image_list.append(self.blank)
|
||||
@ -1116,20 +1156,31 @@ class StockTicker():
|
||||
|
||||
change = float(info['current'])-float(info['opening']) #TEXT
|
||||
ticker = symbol #TEXT
|
||||
current = '%.2f' % float(info['current']) #TEXT
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
try:
|
||||
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'))
|
||||
stitchedStock = self.stitchImage([logo,midFrame])
|
||||
except:
|
||||
|
||||
if all_stocks_settings['logos']:
|
||||
try:
|
||||
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'))
|
||||
stitchedStock = self.stitchImage([logo,midFrame])
|
||||
except:
|
||||
|
||||
stitchedStock = midFrame
|
||||
else:
|
||||
stitchedStock = midFrame
|
||||
|
||||
image_list.append(stitchedStock)
|
||||
@ -1169,32 +1220,42 @@ class StockTicker():
|
||||
|
||||
change = float(info['current'])-float(info['opening']) #TEXT
|
||||
ticker = symbol #TEXT
|
||||
current = '%.2f' % float(info['current']) #TEXT
|
||||
|
||||
|
||||
|
||||
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
|
||||
|
||||
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:
|
||||
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:
|
||||
|
||||
stitchedStock = midFrame
|
||||
else:
|
||||
stitchedStock = midFrame
|
||||
|
||||
image_list.append(stitchedStock)
|
||||
@ -2152,20 +2213,22 @@ class StockTicker():
|
||||
|
||||
def getUserImages(self):
|
||||
|
||||
title_img = self.openImage('feature_titles/images.png')
|
||||
|
||||
|
||||
f = open('csv/image_settings.json', 'r')
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
if all_settings['title']:
|
||||
imgs = [title_img]
|
||||
else:
|
||||
imgs = []
|
||||
|
||||
for image in all_settings['images']:
|
||||
|
||||
|
||||
imgs = []
|
||||
for ind,image in enumerate(all_settings['images']):
|
||||
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
|
||||
@ -2175,15 +2238,30 @@ class StockTicker():
|
||||
all_settings = json.load(f)
|
||||
f.close()
|
||||
|
||||
if all_settings['title']:
|
||||
title_img = self.openImage('feature_titles/gifs.png')
|
||||
GIFs = [title_img]
|
||||
else:
|
||||
GIFs = []
|
||||
GIFs = []
|
||||
|
||||
for f in 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)
|
||||
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'), 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
|
||||
'''
|
||||
|
@ -1988,8 +1988,11 @@
|
||||
id="inputText12"
|
||||
class="form-control pause-select"
|
||||
aria-describedby="TextHelpInline"
|
||||
value={{image_settings.pause}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div class="col-auto">
|
||||
<input
|
||||
class="form-check-input"
|
||||
@ -1999,6 +2002,7 @@
|
||||
checked
|
||||
/>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<div class="row g-3 align-items-center mt-3">
|
||||
@ -2140,8 +2144,10 @@
|
||||
id="inputText112"
|
||||
class="form-control pause-select"
|
||||
aria-describedby="TextHelpInline"
|
||||
value={{GIF_settings.pause}}
|
||||
/>
|
||||
</div>
|
||||
<!--
|
||||
<div class="col-auto">
|
||||
<input
|
||||
class="form-check-input"
|
||||
@ -2151,6 +2157,7 @@
|
||||
checked
|
||||
/>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
|
||||
<div class="row g-3 align-items-center mt-3">
|
||||
|
Loading…
Reference in New Issue
Block a user