added select all button and functionality

This commit is contained in:
UpstreamData
2022-05-05 13:48:57 -06:00
parent 801cfc4ff8
commit 51dae7375f
4 changed files with 49 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ from tools.cfg_util.cfg_util_qt.imgs import FAULT_LIGHT
from tools.cfg_util.cfg_util_qt.tables import clear_tables
from tools.cfg_util.cfg_util_qt.scan import btn_scan
from tools.cfg_util.cfg_util_qt.layout import window
from tools.cfg_util.cfg_util_qt.general import btn_all
import tkinter as tk
sg.set_options(font=("Liberation Mono", 10))
@@ -21,8 +22,28 @@ async def main():
event, value = window.read(0)
if event in (None, "Close", sg.WIN_CLOSED):
sys.exit()
# scan tab
if event == "scan_all":
_table = "scan_table"
btn_all(_table, value[_table])
if event == "btn_scan":
await btn_scan(value["scan_ip"])
# pools tab
if event == "pools_all":
_table = "pools_table"
btn_all(_table, value[_table])
# configure tab
if event == "cfg_all":
_table = "cfg_table"
btn_all(_table, value[_table])
# commands tab
if event == "cmd_all":
_table = "cmd_table"
btn_all(_table, value[_table])
if event == "__TIMEOUT__":
await asyncio.sleep(0)

View File

@@ -0,0 +1,20 @@
from tools.cfg_util.cfg_util_qt.layout import window, TABLE_KEYS
def btn_all(table, selected):
if table in TABLE_KEYS["table"]:
if len(selected) == len(window[table].Values):
window[table].update(select_rows=())
else:
window[table].update(
select_rows=([row for row in range(len(window[table].Values))])
)
if table in TABLE_KEYS["tree"]:
if len(selected) == len(window[table].Widget.get_children()):
_tree = window[table]
_tree.Widget.selection_set([])
else:
_tree = window[table]
rows_to_select = [i for i in _tree.Widget.get_children()]
_tree.Widget.selection_set(rows_to_select)

View File

@@ -114,7 +114,7 @@ def get_scan_layout():
],
[
sg.Table(
values=[[]],
values=[],
headings=[heading for heading in TABLE_HEADERS["SCAN"]],
auto_size_columns=False,
max_col_width=15,

View File

@@ -12,6 +12,13 @@ import logging
progress_bar_len = 0
async def btn_all():
table = "scan_table"
window[table].update(
select_rows=([row for row in range(len(window[table].Values))])
)
async def btn_scan(scan_ip: str):
network = MinerNetwork("192.168.1.0")
if scan_ip: