added the ability to update the treeview and images in it no longer are as buggy

This commit is contained in:
UpstreamData
2022-05-05 14:47:18 -06:00
parent 51dae7375f
commit 26c6e47f1e
4 changed files with 66 additions and 4 deletions

View File

@@ -4,8 +4,8 @@ import sys
import base64
from io import BytesIO
from PIL import ImageTk, Image
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.imgs import FAULT_LIGHT, TkImages
from tools.cfg_util.cfg_util_qt.tables import clear_tables, _update_tree_by_ip
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
@@ -16,6 +16,9 @@ sg.set_options(font=("Liberation Mono", 10))
async def main():
window.read(0)
tk_imgs = TkImages()
# clear_tables()
window["scan_table"].Widget.column(2, anchor=tk.W)
while True:

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +1,5 @@
import PySimpleGUI as sg
from .imgs import WINDOW_ICON, LIGHT
from .imgs import WINDOW_ICON, LIGHT, FAULT_LIGHT
TABLE_HEADERS = {
"SCAN": [
@@ -134,6 +134,8 @@ def get_scan_layout():
def get_command_layout():
data = sg.TreeData()
data.insert("", 0, "", ["", "", ""], icon=FAULT_LIGHT)
data.insert("", 1, "", ["192.168.1.13", "", ""], icon=LIGHT)
col_widths = [
IP_COL_WIDTH,
MODEL_COL_WIDTH,

View File

@@ -4,7 +4,7 @@ from tools.cfg_util.cfg_util_qt.layout import (
TABLE_HEADERS,
window,
)
from tools.cfg_util.cfg_util_qt.imgs import LIGHT
from tools.cfg_util.cfg_util_qt.imgs import TkImages, LIGHT
import PySimpleGUI as sg
@@ -52,3 +52,38 @@ def update_tables(data: list):
window["cmd_table"].update(treedata)
update_miner_count(len(data))
async def _update_tree_by_ip(ip: str, data: dict):
keys = data.keys()
img = None
if "IP" not in keys or "Model" not in keys:
return
_tree = window["cmd_table"].Widget
for iid in _tree.get_children():
values = _tree.item(iid)["values"]
if data.get("Light"):
if data["Light"]:
img = TkImages().fault_light
if not data["Light"]:
img = TkImages().light
if values[0] == ip:
if img:
_tree.item(
iid,
image=img,
values=[
data["IP"],
data["Model"] if "Model" in keys else "",
data["Command Output"] if "Command Output" in keys else "",
],
)
else:
_tree.item(
iid,
values=[
data["IP"],
data["Model"] if "Model" in keys else "",
data["Command Output"] if "Command Output" in keys else "",
],
)