updated red row color on fault light to work with tkinter tags and be sortable.
This commit is contained in:
@@ -65,16 +65,15 @@ async def miner_light(ips: list):
|
|||||||
async def flip_light(ip):
|
async def flip_light(ip):
|
||||||
ip_list = window['ip_table'].Widget
|
ip_list = window['ip_table'].Widget
|
||||||
miner = await miner_factory.get_miner(ip)
|
miner = await miner_factory.get_miner(ip)
|
||||||
index = [item[0] for item in window["ip_table"].Values].index(ip) + 1
|
index = [item[0] for item in window["ip_table"].Values].index(ip)
|
||||||
index_tags = ip_list.item(index)['tags']
|
index_tags = ip_list.item(index + 1)['tags']
|
||||||
if "light" not in index_tags:
|
if "light" not in index_tags:
|
||||||
ip_list.item(index, tags=([*index_tags, "light"]))
|
index_tags.append("light")
|
||||||
window['ip_table'].update(row_colors=[(index, "white", "red")])
|
ip_list.item(index + 1, tags=index_tags)
|
||||||
await miner.fault_light_on()
|
await miner.fault_light_on()
|
||||||
else:
|
else:
|
||||||
index_tags.remove("light")
|
index_tags.remove("light")
|
||||||
ip_list.item(index, tags=index_tags)
|
ip_list.item(index + 1, tags=index_tags)
|
||||||
window['ip_table'].update(row_colors=[(index, "black", "white")])
|
|
||||||
await miner.fault_light_off()
|
await miner.fault_light_off()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -55,35 +55,45 @@ async def set_progress_bar_len(amount):
|
|||||||
|
|
||||||
async def sort_data(index: int or str):
|
async def sort_data(index: int or str):
|
||||||
if window["scan"].Disabled:
|
if window["scan"].Disabled:
|
||||||
print("disabled")
|
|
||||||
return
|
return
|
||||||
await update_ui_with_data("status", "Sorting Data")
|
await update_ui_with_data("status", "Sorting Data")
|
||||||
data_list = window['ip_table'].Values
|
data_list = window['ip_table'].Values
|
||||||
|
table = window["ip_table"].Widget
|
||||||
|
all_data = []
|
||||||
|
for idx, item in enumerate(data_list):
|
||||||
|
all_data.append({"data": item, "tags": table.item(int(idx) + 1)["tags"]})
|
||||||
|
|
||||||
# wattage
|
# wattage
|
||||||
if re.match("[0-9]* W", str(data_list[0][index])):
|
if re.match("[0-9]* W", str(all_data[0]["data"][index])):
|
||||||
new_list = sorted(data_list, key=lambda x: int(x[index].replace(" W", "")))
|
new_list = sorted(all_data, key=lambda x: int(x["data"][index].replace(" W", "")))
|
||||||
if data_list == new_list:
|
if all_data == new_list:
|
||||||
new_list = sorted(data_list, reverse=True, key=lambda x: int(x[index].replace(" W", "")))
|
new_list = sorted(all_data, reverse=True, key=lambda x: int(x["data"][index].replace(" W", "")))
|
||||||
|
|
||||||
# hashrate
|
# hashrate
|
||||||
elif re.match("[0-9]*\.?[0-9]* TH\/s", str(data_list[0][index])):
|
elif re.match("[0-9]*\.?[0-9]* TH\/s", str(all_data[0]["data"][index])):
|
||||||
new_list = sorted(data_list, key=lambda x: float(x[index].replace(" TH/s", "")))
|
new_list = sorted(all_data, key=lambda x: float(x["data"][index].replace(" TH/s", "")))
|
||||||
if data_list == new_list:
|
if all_data == new_list:
|
||||||
new_list = sorted(data_list, reverse=True, key=lambda x: float(x[index].replace(" TH/s", "")))
|
new_list = sorted(all_data, reverse=True, key=lambda x: float(x["data"][index].replace(" TH/s", "")))
|
||||||
|
|
||||||
# ip addresses
|
# ip addresses
|
||||||
elif re.match("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
elif re.match("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",
|
||||||
str(data_list[0][index])):
|
str(all_data[0]["data"][index])):
|
||||||
new_list = sorted(data_list, key=lambda x: ipaddress.ip_address(x[index]))
|
new_list = sorted(all_data, key=lambda x: ipaddress.ip_address(x["data"][index]))
|
||||||
if data_list == new_list:
|
if all_data == new_list:
|
||||||
new_list = sorted(data_list, reverse=True, key=lambda x: ipaddress.ip_address(x[index]))
|
new_list = sorted(all_data, reverse=True, key=lambda x: ipaddress.ip_address(x["data"][index]))
|
||||||
|
|
||||||
# everything else, hostname, temp, and user
|
# everything else, hostname, temp, and user
|
||||||
else:
|
else:
|
||||||
new_list = sorted(data_list, key=lambda x: x[index])
|
new_list = sorted(all_data, key=lambda x: x["data"][index])
|
||||||
if data_list == new_list:
|
if all_data == new_list:
|
||||||
new_list = sorted(data_list, reverse=True, key=lambda x: x[index])
|
new_list = sorted(all_data, reverse=True, key=lambda x: x["data"][index])
|
||||||
|
|
||||||
|
new_data = []
|
||||||
|
for item in new_list:
|
||||||
|
new_data.append(item["data"])
|
||||||
|
|
||||||
|
await update_ui_with_data("ip_table", new_data)
|
||||||
|
for idx, item in enumerate(new_list):
|
||||||
|
table.item(idx + 1, tags=item["tags"])
|
||||||
|
|
||||||
await update_ui_with_data("ip_table", new_list)
|
|
||||||
await update_ui_with_data("status", "")
|
await update_ui_with_data("status", "")
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ async def ui():
|
|||||||
window.read(timeout=0)
|
window.read(timeout=0)
|
||||||
table = window["ip_table"].Widget
|
table = window["ip_table"].Widget
|
||||||
table.bind("<Control-Key-c>", lambda x: copy_from_table(table))
|
table.bind("<Control-Key-c>", lambda x: copy_from_table(table))
|
||||||
|
# light tag shows red row for fault lights
|
||||||
|
table.tag_configure("light", foreground="white", background="red")
|
||||||
# left justify the hostnames
|
# left justify the hostnames
|
||||||
table.column(2, anchor=tk.W)
|
table.column(2, anchor=tk.W)
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Reference in New Issue
Block a user