Compact the look a bit

kivy_mainline_and_py3.8
Tyler Goodlet 2018-11-13 18:41:40 -05:00
parent 5961e458cf
commit 6a66b056c8
1 changed files with 11 additions and 5 deletions

View File

@ -41,7 +41,7 @@ def colorcode(name):
return _colors[name if name else 'gray'] return _colors[name if name else 'gray']
_bs = 3 # border size _bs = 4 # border size
_color = [0.13]*3 # nice shade of gray _color = [0.13]*3 # nice shade of gray
_kv = (f''' _kv = (f'''
#:kivy 1.10.0 #:kivy 1.10.0
@ -74,7 +74,7 @@ _kv = (f'''
<TickerTable> <TickerTable>
spacing: '{_bs}dp' spacing: '{_bs}dp'
row_force_default: True row_force_default: True
row_default_height: 75 row_default_height: 63
cols: 1 cols: 1
<BidAskLayout> <BidAskLayout>
@ -143,7 +143,7 @@ class BidAskLayout(StackLayout):
cell_type = HeaderCell if header else Cell cell_type = HeaderCell if header else Cell
top_size = cell_type().font_size top_size = cell_type().font_size
small_size = top_size - 2 small_size = top_size - 2
top_prop = 0.7 # proportion of size used by top cell top_prop = 0.55 # proportion of size used by top cell
bottom_prop = 1 - top_prop bottom_prop = 1 - top_prop
for (key, size_hint, font_size), value in zip( for (key, size_hint, font_size), value in zip(
[('last', (1, top_prop), top_size), [('last', (1, top_prop), top_size),
@ -175,6 +175,7 @@ class BidAskLayout(StackLayout):
@row.setter @row.setter
def row(self, row): def row(self, row):
# so hideous
for cell in self.cells: for cell in self.cells:
cell.row = row cell.row = row
@ -338,7 +339,11 @@ async def update_quotes(
else: else:
color = colorcode('gray') color = colorcode('gray')
# row header and % cell color
chngcell.color = hdrcell.color = color chngcell.color = hdrcell.color = color
# bgcolor = color.copy()
# bgcolor[-1] = 0.25
# chngcell.background_color = bgcolor
# if the cell has been "highlighted" make sure to change its color # if the cell has been "highlighted" make sure to change its color
if hdrcell.background_color != [0]*4: if hdrcell.background_color != [0]*4:
@ -356,9 +361,10 @@ async def update_quotes(
color_row(row, record) color_row(row, record)
cache[sym] = (record, row) cache[sym] = (record, row)
# render all rows once up front
grid.render_rows(cache) grid.render_rows(cache)
# core cell update loop # real-time cell update loop
async for quotes in agen: # new quotes data only async for quotes in agen: # new quotes data only
for symbol, quote in quotes.items(): for symbol, quote in quotes.items():
record, displayable = brokermod.format_quote( record, displayable = brokermod.format_quote(
@ -378,7 +384,7 @@ async def update_quotes(
async def _async_main(name, portal, tickers, brokermod, rate): async def _async_main(name, portal, tickers, brokermod, rate):
'''Launch kivy app + all other related tasks. '''Launch kivy app + all other related tasks.
This is started with cli command `piker watch`. This is started with cli cmd `piker monitor`.
''' '''
# subscribe for tickers (this performs a possible filtering # subscribe for tickers (this performs a possible filtering
# where invalid symbols are discarded) # where invalid symbols are discarded)