changed sorting to show up on the table headers
This commit is contained in:
@@ -114,13 +114,6 @@ MINER_COUNT_BUTTONS = [
|
|||||||
"pools_miner_count",
|
"pools_miner_count",
|
||||||
]
|
]
|
||||||
|
|
||||||
SORT_KEY_BUTTONS = [
|
|
||||||
"scan_sort_key",
|
|
||||||
"cmd_sort_key",
|
|
||||||
"cfg_sort_key",
|
|
||||||
"pools_sort_key",
|
|
||||||
]
|
|
||||||
|
|
||||||
HASHRATE_TOTAL_BUTTONS = [
|
HASHRATE_TOTAL_BUTTONS = [
|
||||||
"scan_total_hashrate",
|
"scan_total_hashrate",
|
||||||
"cfg_total_hashrate",
|
"cfg_total_hashrate",
|
||||||
@@ -149,15 +142,15 @@ BUTTON_KEYS = [
|
|||||||
|
|
||||||
TABLE_HEIGHT = 27
|
TABLE_HEIGHT = 27
|
||||||
|
|
||||||
IMAGE_COL_WIDTH = 6
|
IMAGE_COL_WIDTH = 8
|
||||||
IP_COL_WIDTH = 17
|
IP_COL_WIDTH = 17
|
||||||
MODEL_COL_WIDTH = 15
|
MODEL_COL_WIDTH = 15
|
||||||
HOST_COL_WIDTH = 15
|
HOST_COL_WIDTH = 15
|
||||||
HASHRATE_COL_WIDTH = 12
|
HASHRATE_COL_WIDTH = 12
|
||||||
TEMP_COL_WIDTH = 12
|
TEMP_COL_WIDTH = 14
|
||||||
USER_COL_WIDTH = 31
|
USER_COL_WIDTH = 27
|
||||||
WATTAGE_COL_WIDTH = 8
|
WATTAGE_COL_WIDTH = 10
|
||||||
SPLIT_COL_WIDTH = 6
|
SPLIT_COL_WIDTH = 8
|
||||||
SCAN_COL_WIDTHS = [
|
SCAN_COL_WIDTHS = [
|
||||||
IP_COL_WIDTH,
|
IP_COL_WIDTH,
|
||||||
MODEL_COL_WIDTH,
|
MODEL_COL_WIDTH,
|
||||||
@@ -199,13 +192,6 @@ def get_scan_layout():
|
|||||||
mouseover_colors=BTN_DISABLED,
|
mouseover_colors=BTN_DISABLED,
|
||||||
),
|
),
|
||||||
sg.Push(background_color=MAIN_TABS_BG),
|
sg.Push(background_color=MAIN_TABS_BG),
|
||||||
sg.Button(
|
|
||||||
"Sort: IP",
|
|
||||||
disabled=True,
|
|
||||||
button_color=("black", "white smoke"),
|
|
||||||
disabled_button_color=("black", "white smoke"),
|
|
||||||
key="scan_sort_key",
|
|
||||||
),
|
|
||||||
sg.Button(
|
sg.Button(
|
||||||
"Hashrate: 0 TH/s",
|
"Hashrate: 0 TH/s",
|
||||||
disabled=True,
|
disabled=True,
|
||||||
@@ -284,13 +270,6 @@ def get_command_layout():
|
|||||||
disabled_button_color=BTN_DISABLED,
|
disabled_button_color=BTN_DISABLED,
|
||||||
),
|
),
|
||||||
sg.Push(background_color=MAIN_TABS_BG),
|
sg.Push(background_color=MAIN_TABS_BG),
|
||||||
sg.Button(
|
|
||||||
"Sort: IP",
|
|
||||||
disabled=True,
|
|
||||||
button_color=("black", "white smoke"),
|
|
||||||
disabled_button_color=("black", "white smoke"),
|
|
||||||
key="cmd_sort_key",
|
|
||||||
),
|
|
||||||
sg.Button(
|
sg.Button(
|
||||||
"Miners: 0",
|
"Miners: 0",
|
||||||
disabled=True,
|
disabled=True,
|
||||||
@@ -380,13 +359,6 @@ def get_pools_layout():
|
|||||||
disabled_button_color=BTN_DISABLED,
|
disabled_button_color=BTN_DISABLED,
|
||||||
),
|
),
|
||||||
sg.Push(background_color=MAIN_TABS_BG),
|
sg.Push(background_color=MAIN_TABS_BG),
|
||||||
sg.Button(
|
|
||||||
"Sort: IP",
|
|
||||||
disabled=True,
|
|
||||||
button_color=("black", "white smoke"),
|
|
||||||
disabled_button_color=("black", "white smoke"),
|
|
||||||
key="pools_sort_key",
|
|
||||||
),
|
|
||||||
sg.Button(
|
sg.Button(
|
||||||
"Hashrate: 0 TH/s",
|
"Hashrate: 0 TH/s",
|
||||||
disabled=True,
|
disabled=True,
|
||||||
@@ -534,13 +506,6 @@ def get_config_layout():
|
|||||||
disabled_button_color=BTN_DISABLED,
|
disabled_button_color=BTN_DISABLED,
|
||||||
),
|
),
|
||||||
sg.Push(background_color=MAIN_TABS_BG),
|
sg.Push(background_color=MAIN_TABS_BG),
|
||||||
sg.Button(
|
|
||||||
"Sort: IP",
|
|
||||||
disabled=True,
|
|
||||||
button_color=("black", "white smoke"),
|
|
||||||
disabled_button_color=("black", "white smoke"),
|
|
||||||
key="cfg_sort_key",
|
|
||||||
),
|
|
||||||
sg.Button(
|
sg.Button(
|
||||||
"Hashrate: 0 TH/s",
|
"Hashrate: 0 TH/s",
|
||||||
disabled=True,
|
disabled=True,
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from tools.cfg_util.layout import (
|
from tools.cfg_util.layout import (
|
||||||
MINER_COUNT_BUTTONS,
|
MINER_COUNT_BUTTONS,
|
||||||
HASHRATE_TOTAL_BUTTONS,
|
HASHRATE_TOTAL_BUTTONS,
|
||||||
SORT_KEY_BUTTONS,
|
|
||||||
TABLE_KEYS,
|
TABLE_KEYS,
|
||||||
TABLE_HEADERS,
|
TABLE_HEADERS,
|
||||||
window,
|
window,
|
||||||
@@ -25,11 +24,6 @@ def update_total_hr(hashrate: float):
|
|||||||
window[button].update(f"Hashrate: {hashrate}")
|
window[button].update(f"Hashrate: {hashrate}")
|
||||||
|
|
||||||
|
|
||||||
def update_sort_key_btns():
|
|
||||||
for button in SORT_KEY_BUTTONS:
|
|
||||||
window[button].update(f"Sort: {TableManager().sort_key}")
|
|
||||||
|
|
||||||
|
|
||||||
def update_tables(data: list or None = None):
|
def update_tables(data: list or None = None):
|
||||||
TableManager().update_data(data)
|
TableManager().update_data(data)
|
||||||
|
|
||||||
@@ -64,10 +58,11 @@ class TableManager(metaclass=Singleton):
|
|||||||
self.update_item(line)
|
self.update_item(line)
|
||||||
|
|
||||||
def update_sort_key(self, sort_key):
|
def update_sort_key(self, sort_key):
|
||||||
|
if "▲" in sort_key or "▼" in sort_key:
|
||||||
|
sort_key = sort_key[:-1]
|
||||||
if self.sort_key == sort_key:
|
if self.sort_key == sort_key:
|
||||||
self.sort_reverse = not self.sort_reverse
|
self.sort_reverse = not self.sort_reverse
|
||||||
self.sort_key = sort_key
|
self.sort_key = sort_key
|
||||||
update_sort_key_btns()
|
|
||||||
self.update_tables()
|
self.update_tables()
|
||||||
|
|
||||||
def update_item(self, data: dict):
|
def update_item(self, data: dict):
|
||||||
@@ -100,6 +95,39 @@ class TableManager(metaclass=Singleton):
|
|||||||
ip_sorted_keys, reverse=self.sort_reverse, key=lambda x: self._get_sort(x)
|
ip_sorted_keys, reverse=self.sort_reverse, key=lambda x: self._get_sort(x)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
table_names = {
|
||||||
|
"SCAN": "scan_table",
|
||||||
|
"POOLS_ALL": "pools_table",
|
||||||
|
"POOLS_1": "pools_1_table",
|
||||||
|
"POOLS_2": "pools_2_table",
|
||||||
|
"CONFIG": "cfg_table",
|
||||||
|
"CMD": "cmd_table",
|
||||||
|
}
|
||||||
|
|
||||||
|
for table in TABLE_HEADERS.keys():
|
||||||
|
widget = window[table_names[table]].Widget
|
||||||
|
for idx, header in enumerate(TABLE_HEADERS[table]):
|
||||||
|
_header = header
|
||||||
|
if header == self.sort_key:
|
||||||
|
if self.sort_reverse:
|
||||||
|
_header = f"{header}▼"
|
||||||
|
else:
|
||||||
|
_header = f"{header}▲"
|
||||||
|
widget.heading(idx, text=_header)
|
||||||
|
|
||||||
|
# reset light
|
||||||
|
window["cmd_table"].Widget.heading("#0", text="Light")
|
||||||
|
|
||||||
|
# handle light sort key
|
||||||
|
if self.sort_key == "Light":
|
||||||
|
widget = window["cmd_table"].Widget
|
||||||
|
idx = "#0"
|
||||||
|
if self.sort_reverse:
|
||||||
|
_header = f"Light▼"
|
||||||
|
else:
|
||||||
|
_header = f"Light▲"
|
||||||
|
widget.heading(idx, text=_header)
|
||||||
|
|
||||||
for data_idx, key in enumerate(sorted_keys):
|
for data_idx, key in enumerate(sorted_keys):
|
||||||
item = self.data[key]
|
item = self.data[key]
|
||||||
keys = item.keys()
|
keys = item.keys()
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ def _tree_header_click_handler(event, table):
|
|||||||
|
|
||||||
async def ui():
|
async def ui():
|
||||||
window.read(0)
|
window.read(0)
|
||||||
|
TableManager().update_tables()
|
||||||
|
|
||||||
# create images used in the table, they will not show if not saved here
|
# create images used in the table, they will not show if not saved here
|
||||||
tk_imgs = TkImages()
|
tk_imgs = TkImages()
|
||||||
|
|||||||
Reference in New Issue
Block a user