E-Paper-Calendar/Calendar/CryptoListDesign.py

28 lines
1.2 KiB
Python
Raw Normal View History

2019-05-18 09:28:29 +02:00
from DesignEntity import DesignEntity
from TableDesign import TableDesign
from Assets import defaultfontsize
from CryptoPrices import CryptoPrices
2019-05-18 09:35:49 +02:00
from settings import crypto_coins as cryptos
2019-05-18 09:28:29 +02:00
class CryptoListDesign (DesignEntity):
def __init__ (self, size, coin, text_size = defaultfontsize):
super(CryptoListDesign, self).__init__(size)
self.coin = coin
2019-05-19 01:20:51 +02:00
self.__post_matrix__ = []
2019-05-18 09:28:29 +02:00
self.text_size = text_size
def __finish_image__ (self):
self.__fill_post_matrix__()
2019-05-19 01:20:51 +02:00
table_design = TableDesign(self.size, column_horizontal_alignments = ["Right"], line_spacing=2, col_spacing=3, matrix=self.__post_matrix__, fontsize = self.text_size, mask=False, wrap=True, truncate_rows=True)
2019-05-18 09:28:29 +02:00
self.draw_design(table_design)
2019-05-19 01:20:51 +02:00
def format_price(self,prices,coins,daychange):
return [ '', coins,' | ','$',prices,' | %',daychange]
2019-05-18 09:28:29 +02:00
def __fill_post_matrix__ (self):
2019-05-19 01:20:51 +02:00
prices, coins, daychanges = CryptoPrices.__get_prices__(self.coin)
for price, coin, daychange in zip(prices, coins, daychanges):
row=self.format_price(str(price), coin, str(daychange))
self.__post_matrix__.append(row)