31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from _tkinter import Tcl_Obj
|
|
import tkinter as tk
|
|
|
|
import gui.GuiCommon as gcm
|
|
|
|
class TerminalDisplay(tk.Text):
|
|
# global terminal-style outlook
|
|
TERMINAL_STYLE = {
|
|
"wrap": tk.WORD,
|
|
"background": "#3D3D3D",
|
|
"borderwidth": 0,
|
|
"foreground": "white",
|
|
"blockcursor": True,
|
|
"insertbackground": "white"
|
|
}
|
|
|
|
def __init__(self, master: tk.Widget) -> None:
|
|
super().__init__(master=master, **self.TERMINAL_STYLE, font=gcm.TERMINAL_FONT, state=tk.DISABLED)
|
|
|
|
def insert(self, index: str | float | Tcl_Obj | tk.Widget, chars: str, *args: str | list[str] | tuple[str, ...]) -> None:
|
|
self.configure(state=tk.NORMAL)
|
|
ret = super().insert(index, chars, *args)
|
|
self.yview(tk.END)
|
|
self.configure(state=tk.DISABLED)
|
|
return ret
|
|
|
|
def delete(self, index1: str | float | Tcl_Obj | tk.Widget, index2: str | float | Tcl_Obj | tk.Widget | None = None) -> None:
|
|
self.configure(state=tk.NORMAL)
|
|
ret = super().delete(index1, index2)
|
|
self.configure(state=tk.DISABLED)
|
|
return ret |