update log text color
This commit is contained in:
13
utils.py
13
utils.py
@@ -1,6 +1,7 @@
|
||||
import json
|
||||
import datetime
|
||||
import threading
|
||||
import tkinter as tk
|
||||
|
||||
def save_json(path, key, value):
|
||||
with open(path, "r") as fp:
|
||||
@@ -9,11 +10,19 @@ def save_json(path, key, value):
|
||||
with open(path, "w") as fp:
|
||||
json.dump(json_data, fp, indent=4)
|
||||
|
||||
def print_textbox(textbox, message):
|
||||
def print_textbox(textbox, message, tags=None):
|
||||
now = datetime.datetime.now()
|
||||
now = now.strftime('%H:%M:%S')
|
||||
|
||||
textbox.tag_config("ERROR", foreground="#FF0000")
|
||||
textbox.tag_config("INFO", foreground="#1BFF00")
|
||||
textbox.tag_config("SEND", foreground="#0378e2")
|
||||
textbox.tag_config("RECEIVE", foreground="#ffa500")
|
||||
|
||||
textbox.configure(state='normal')
|
||||
textbox.insert("end", f"[{now}]{message}\n")
|
||||
textbox.insert("end", f"[{now}][")
|
||||
textbox.insert("end", f"{tags}", tags)
|
||||
textbox.insert("end", f"]{message}\n")
|
||||
textbox.configure(state='disabled')
|
||||
textbox.see("end")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user