fixed formatting on hashrate

This commit is contained in:
UpstreamData
2022-05-05 12:07:57 -06:00
parent b756c9e4a1
commit 1b22810f4b
7 changed files with 44 additions and 13 deletions

View File

@@ -1,4 +1,9 @@
from tools.cfg_util.cfg_util_qt.layout import TABLE_KEYS, TABLE_HEADERS, window
from tools.cfg_util.cfg_util_qt.layout import (
MINER_COUNT_BUTTONS,
TABLE_KEYS,
TABLE_HEADERS,
window,
)
from tools.cfg_util.cfg_util_qt.imgs import LIGHT
import PySimpleGUI as sg
@@ -8,6 +13,12 @@ def clear_tables():
window[table].update([])
for tree in TABLE_KEYS["tree"]:
window[tree].update(sg.TreeData())
update_miner_count(0)
def update_miner_count(count):
for button in MINER_COUNT_BUTTONS:
window[button].update(f"Miners: {count}")
def update_tables(data: list):
@@ -18,7 +29,13 @@ def update_tables(data: list):
"CONFIG": [["" for _ in TABLE_HEADERS["CONFIG"]] for _ in data],
}
for data_idx, item in enumerate(data):
for key in item.keys():
keys = item.keys()
if "Hashrate" in keys:
if not isinstance(item["Hashrate"], str):
item[
"Hashrate"
] = f"{format(float(item['Hashrate']), '.2f').rjust(6, ' ')} TH/s"
for key in keys:
for table in TABLE_HEADERS.keys():
for idx, header in enumerate(TABLE_HEADERS[table]):
if key == header:
@@ -33,3 +50,5 @@ def update_tables(data: list):
treedata.insert("", idx, "", item, icon=LIGHT)
window["cmd_table"].update(treedata)
update_miner_count(len(data))