41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
import tkinter as tk
|
|
from tkinter import ttk
|
|
from typing import Literal
|
|
|
|
from gui.TerminalDisplay import TerminalDisplay
|
|
|
|
class LoggingTab(ttk.Frame):
|
|
def __init_layout(self) -> None:
|
|
self.rowconfigure(0, weight=8)
|
|
self.rowconfigure(1, weight=2)
|
|
|
|
self.columnconfigure(0, weight=1)
|
|
self.columnconfigure(1, weight=1)
|
|
|
|
def __init_widgets(self) -> None:
|
|
self.__flexPtp_log = TerminalDisplay(self)
|
|
self.__flexPtp_log.grid(column=0, row=0, sticky=tk.NSEW)
|
|
|
|
self.__linuxptp_log = TerminalDisplay(self)
|
|
self.__linuxptp_log.grid(column=1, row=0, sticky=tk.NSEW)
|
|
|
|
def __init__(self, notebook: ttk.Notebook) -> None:
|
|
super().__init__(master=notebook)
|
|
notebook.add(self, text="Logs")
|
|
|
|
self.__init_layout() # initialize widget layout
|
|
self.__init_widgets() # initialize widgets
|
|
|
|
def clear_log(self, which: Literal["flexPTP", "linuxptp", "both"]) -> None:
|
|
if which in ("flexPTP", "both"):
|
|
self.__flexPtp_log.delete(1, tk.END)
|
|
|
|
if which in ("linuxptp", "both"):
|
|
self.__linuxptp_log.delete(1, tk.END)
|
|
|
|
def add_log(self, which: Literal["flexPTP", "linuxptp", "both"], what: str) -> None:
|
|
if which in ("flexPTP", "both"):
|
|
self.__flexPtp_log.insert(tk.END, what)
|
|
|
|
if which in ("linuxptp", "both"):
|
|
self.__linuxptp_log.insert(tk.END, what) |