Initial commit
This commit is contained in:
commit
184b0e6033
18 changed files with 1178 additions and 0 deletions
44
full_updater/ui/log_panel.py
Normal file
44
full_updater/ui/log_panel.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from textual.widgets import RichLog, Button
|
||||
from textual.containers import Vertical, Horizontal
|
||||
from textual.message import Message
|
||||
|
||||
|
||||
class LogPanel(Vertical):
|
||||
DEFAULT_CSS = """
|
||||
LogPanel {
|
||||
padding: 1 2;
|
||||
}
|
||||
#log-toolbar {
|
||||
height: auto;
|
||||
margin-bottom: 1;
|
||||
}
|
||||
RichLog {
|
||||
height: 1fr;
|
||||
border: solid $primary;
|
||||
}
|
||||
"""
|
||||
|
||||
class BackPressed(Message):
|
||||
pass
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.log = None
|
||||
|
||||
def compose(self):
|
||||
with Horizontal(id="log-toolbar"):
|
||||
yield Button("⬅ Retour", id="log-back")
|
||||
self.log = RichLog(id="log-view", highlight=True)
|
||||
yield self.log
|
||||
|
||||
def write(self, line: str):
|
||||
if self.log:
|
||||
self.log.write(line)
|
||||
|
||||
def clear(self):
|
||||
if self.log:
|
||||
self.log.clear()
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed):
|
||||
if event.button.id == "log-back":
|
||||
self.post_message(self.BackPressed())
|
||||
Loading…
Add table
Add a link
Reference in a new issue