added sorting to the 3 main tables

This commit is contained in:
UpstreamData
2022-05-06 12:03:43 -06:00
parent a2b071af4f
commit 8cc6f66458
4 changed files with 19 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ from tools.cfg_util.cfg_util_qt.scan import btn_scan
from tools.cfg_util.cfg_util_qt.commands import btn_light
from tools.cfg_util.cfg_util_qt.layout import window
from tools.cfg_util.cfg_util_qt.general import btn_all
from tools.cfg_util.cfg_util_qt.tables import TableManager
import tkinter as tk
sg.set_options(font=("Liberation Mono", 10))
@@ -22,6 +23,16 @@ async def main():
event, value = window.read(0)
if event in (None, "Close", sg.WIN_CLOSED):
sys.exit()
if isinstance(event, tuple):
if len(window["scan_table"].Values) > 0:
if event[0].endswith("_table"):
if event[2][0] == -1:
mgr = TableManager()
table = window[event[0]].Widget
mgr.sort_key = table.heading(event[2][1])["text"]
mgr.update_tables()
# scan tab
if event == "scan_all":
_table = "scan_table"

View File

@@ -174,6 +174,7 @@ def get_command_layout():
expand_y=True,
col0_heading="Light",
col0_width=IMAGE_COL_WIDTH,
enable_events=True,
)
],
]

View File

@@ -50,6 +50,7 @@ async def _scan_miners(network: MinerNetwork):
MinerFactory().clear_cached_miners()
global progress_bar_len
progress_bar_len = 0
network_size = len(network)
await update_prog_bar(progress_bar_len, max=(3 * network_size))

View File

@@ -73,9 +73,12 @@ class TableManager(metaclass=Singleton):
"POOLS": [["" for _ in TABLE_HEADERS["POOLS"]] for _ in self.data],
"CONFIG": [["" for _ in TABLE_HEADERS["CONFIG"]] for _ in self.data],
}
for data_idx, key in enumerate(
sorted(self.data.keys(), key=lambda x: self._get_sort(x))
):
sorted_keys = sorted(self.data.keys(), key=lambda x: self._get_sort(x))
if sorted_keys == list(self.data.keys()):
sorted_keys = sorted(
self.data.keys(), key=lambda x: ipaddress.ip_address(x)
)
for data_idx, key in enumerate(sorted_keys):
item = self.data[key]
keys = item.keys()