From 71e6df76ce6a5c47d7f44cd3c158472a8484c4f3 Mon Sep 17 00:00:00 2001 From: Huy Pham <42948410+hpham@users.noreply.github.com> Date: Thu, 12 Dec 2019 10:49:52 -0800 Subject: [PATCH] create layout for check emulation light dialog --- coretk/coretk/data/icons/alert.png | Bin 0 -> 2019 bytes coretk/coretk/dialogs/cel.py | 78 +++++++++++++++++++++++------ coretk/coretk/images.py | 1 + coretk/coretk/statusbar.py | 7 ++- 4 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 coretk/coretk/data/icons/alert.png diff --git a/coretk/coretk/data/icons/alert.png b/coretk/coretk/data/icons/alert.png new file mode 100644 index 0000000000000000000000000000000000000000..718fa9f1f2794dc3165f2cf71db560247721c52b GIT binary patch literal 2019 zcmV<92ORi`P)!Qp@lUfU%Db%W|ox?Bz|gZ z*$7A@n3z;FF-GY6FJY@OxU>;W{P&Sqq-~ZzOZ;Hshq}xxsKHjFsiN6x)MAUWrGc_2 zyVK)`ohj?ieQ)l&?@V`gdw_kR z|GUf&^2iDv0b1gIgwMZqfsyke2s+3p%KeKj?a)EK7AjAIj3~1WcsxPkm{j;us6m~K z!}(`#A>1kzp3EvUa{zP`S5o9K(3>K4)deBN`3+7XY?KOr%_29`6r=-m)5U($oDZvR zI`VKnz{MyB^ja>+B0JkV;6lEM@*%Ib3qcsoB)D>Er8Jh^_aTw^% zqF^OYM;V>pU>+EdD!=n->@@-ugc{!^tMeB+ugK{r(D?ve!1vVi;r5$?O56q96kyB( zD=Y{(oZp~CnNRpMY#Al}C~J6~qbQf>FsPxe#8wtkFZ}1n2^vfjkNe$9Rz;W)t+WF9N zKT+G{e1NN{aa&r0^Z*E-F*WD^c~=`{XG2>oEc3A=?Pg*CbdamTbJ3L*yi z;WEAeOteY*Cf&sPq?^ejK-o^VK|Tb|>$=5mdY3cmrq z(+1J&xsms|Zny&=e8k)Y;YHrYH_YW)Q)Cx#++1#fo86aPsJn44ls)n@UN@I(j7)MG zWskXFWyqt*0#L-jMP<;uJP&}+GXKDMH41~vj$)NdUF4kJu3!$hm)e@i{L z(8C-24d}}wX9*{%@(zJBi!U~hfD`m%>wJKHxt(8T8@>DyWj}B`&=2&~|N4R3Q4Y|{ zA9Rq9<GC%aCsMQ)4+mz zBLjjfECkL-m7Ty={HDigV2e~4 zS(<&ysQAv{zDX3DeVde${5Nokq3RiCdAA&5HjfY;pqsU9LD-BkfYeix%CY)S%?W0C zI(W`+=sAZe$*!fXWSp9oses{T81&J@r^#9JQFrWk{jYuehaK2DACyVgh)k-AIB2ST zf&26pdfFh@6dht6nkxz9M)HCRA(xbqvB1wr_-Pno>eK7D;*b`ac$3_Jv^2au-Q++$wW^gBC$hluu>-Vj=|AhRPH_0ms)xR;lwF zqy*usGR0Hp+#oIU(AiJ;mfG^UmySeBj4b+e@$zjdDipNL{`1NC4eCMIpYtT9fgv5V zuYayNpa1trBoc{4B9TZW5{X12kw_#Gi9{m){15#$Llp7S@m>G`002ovPDHLkV1gy+ B*;oJo literal 0 HcmV?d00001 diff --git a/coretk/coretk/dialogs/cel.py b/coretk/coretk/dialogs/cel.py index a5fbea63..77b96367 100644 --- a/coretk/coretk/dialogs/cel.py +++ b/coretk/coretk/dialogs/cel.py @@ -5,34 +5,70 @@ import tkinter as tk from tkinter import ttk from coretk.dialogs.dialog import Dialog +from coretk.themes import PADX, PADY +from coretk.widgets import CodeText class CheckLight(Dialog): def __init__(self, master, app): super().__init__(master, app, "CEL", modal=True) self.app = app - - self.columnconfigure(0, weight=1) + self.tree = None self.draw() def draw(self): row = 0 frame = ttk.Frame(self) + frame.columnconfigure(0, weight=1) label = ttk.Label(frame, text="Check Emulation Light") label.grid(row=0, column=0) - frame.grid(row=row, column=0) + frame.grid(row=row, column=0, padx=PADX, pady=PADY, sticky="nsew") row = row + 1 + frame = ttk.Frame(self) - button = ttk.Button(frame, text="Reset CEL") - button.grid(row=0, column=0) - button = ttk.Button(frame, text="View core-daemon log", command=self.daemon_log) - button.grid(row=0, column=1) - button = ttk.Button(frame, text="View node log") - button.grid(row=0, column=2) - button = ttk.Button(frame, text="Close", command=self.destroy) - button.grid(row=0, column=3) + frame.columnconfigure(0, weight=1) frame.grid(row=row, column=0, sticky="nsew") - ++row + self.tree = ttk.Treeview( + frame, columns=("time", "level", "node", "source"), show="headings" + ) + self.tree.grid(row=0, column=0, sticky="nsew") + self.tree.column("time", stretch=tk.YES) + self.tree.heading("time", text="time") + self.tree.column("level", stretch=tk.YES) + self.tree.heading("level", text="level") + self.tree.column("node", stretch=tk.YES) + self.tree.heading("node", text="node") + self.tree.column("source", stretch=tk.YES) + self.tree.heading("source", text="source") + + yscrollbar = ttk.Scrollbar(frame, orient="vertical", command=self.tree.yview) + yscrollbar.grid(row=0, column=1, sticky="ns") + self.tree.configure(yscrollcommand=yscrollbar.set) + + xscrollbar = ttk.Scrollbar(frame, orient="horizontal", command=self.tree.xview) + xscrollbar.grid(row=1, sticky="ew") + self.tree.configure(xscrollcommand=xscrollbar.set) + row = row + 1 + + text = CodeText(self) + text.grid(row=row, column=0, sticky="nsew") + row = row + 1 + + frame = ttk.Frame(self) + frame.columnconfigure(0, weight=1) + frame.columnconfigure(1, weight=1) + frame.columnconfigure(2, weight=1) + frame.columnconfigure(3, weight=1) + button = ttk.Button(frame, text="Reset CEL") + button.grid(row=0, column=0, sticky="nsew", padx=PADX) + button = ttk.Button(frame, text="View core-daemon log", command=self.daemon_log) + button.grid(row=0, column=1, sticky="nsew", padx=PADX) + button = ttk.Button(frame, text="View node log") + button.grid(row=0, column=2, sticky="nsew", padx=PADX) + button = ttk.Button(frame, text="Close", command=self.destroy) + button.grid(row=0, column=3, sticky="nsew", padx=PADX) + frame.grid(row=row, column=0, sticky="nsew") + row = row + 1 def daemon_log(self): dialog = DaemonLog(self, self.app) @@ -48,8 +84,20 @@ class DaemonLog(Dialog): def draw(self): frame = ttk.Frame(self) + frame.columnconfigure(0, weight=1) + frame.columnconfigure(1, weight=9) label = ttk.Label(frame, text="File: ") label.grid(row=0, column=0) - entry = ttk.Entry(frame, textvariable=self.path, state="readonly") - entry.grid(row=0, column=1) - frame.grid(row=0, column=0) + entry = ttk.Entry(frame, textvariable=self.path, state="disabled") + entry.grid(row=0, column=1, sticky="nsew") + frame.grid(row=0, column=0, sticky="nsew") + try: + file = open("/var/log/core-daemon.log", "r") + log = file.readlines() + except FileNotFoundError: + log = "Log file not found" + text = CodeText(self) + text.insert("1.0", log) + text.see("end") + text.config(state=tk.DISABLED) + text.grid(row=1, column=0, sticky="nsew") diff --git a/coretk/coretk/images.py b/coretk/coretk/images.py index db7928b9..9d282dbb 100644 --- a/coretk/coretk/images.py +++ b/coretk/coretk/images.py @@ -67,3 +67,4 @@ class ImageEnum(Enum): ANTENNA = "antenna" DOCKER = "docker" LXC = "lxc" + ALERT = "alert" diff --git a/coretk/coretk/statusbar.py b/coretk/coretk/statusbar.py index f45dce9f..797d61a8 100644 --- a/coretk/coretk/statusbar.py +++ b/coretk/coretk/statusbar.py @@ -3,6 +3,7 @@ import tkinter as tk from tkinter import ttk from coretk.dialogs.cel import CheckLight +from coretk.images import ImageEnum, Images class StatusBar(ttk.Frame): @@ -54,9 +55,11 @@ class StatusBar(ttk.Frame): ) self.cpu_usage.grid(row=0, column=3, sticky="ew") - self.emulation_light = ttk.Label( - self, text="CEL TBD", anchor=tk.CENTER, borderwidth=1, relief=tk.RIDGE + image = Images.get(ImageEnum.ALERT, 18) + self.emulation_light = ttk.Button( + self, image=image, text="Alert", compound="left" ) + self.emulation_light.image = image self.emulation_light.bind("", self.cel_callback) self.emulation_light.grid(row=0, column=4, sticky="ew")