create layout for check emulation light dialog

This commit is contained in:
Huy Pham 2019-12-12 10:49:52 -08:00
parent a7e1035f5a
commit 71e6df76ce
4 changed files with 69 additions and 17 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -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")

View file

@ -67,3 +67,4 @@ class ImageEnum(Enum):
ANTENNA = "antenna"
DOCKER = "docker"
LXC = "lxc"
ALERT = "alert"

View file

@ -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("<Button-1>", self.cel_callback)
self.emulation_light.grid(row=0, column=4, sticky="ew")