Last active
July 21, 2025 20:52
-
-
Save mpentler/347b32f9254e73f4f7a457fd07ce1277 to your computer and use it in GitHub Desktop.
CLI VIdeo player debug panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Horrorbox v1.4 | |
| # Debug panel class | |
| import urwid | |
| from ui.safe_listbox import SafeListBox | |
| from datetime import datetime | |
| class DebugPanel: | |
| def __init__(self, max_lines=10): | |
| self.max_lines = max_lines | |
| self.messages = [] | |
| self.walker = urwid.SimpleFocusListWalker([]) | |
| self.listbox = SafeListBox(self.walker) | |
| self.box = urwid.BoxAdapter(self.listbox, height=max_lines) | |
| self.widget = urwid.AttrMap(self.box, 'footer') | |
| def add_message(self, msg): | |
| timestamp = datetime.now().strftime("%H:%M:%S") | |
| self.messages.append(f"[{timestamp}] {msg}") | |
| if len(self.messages) > 100: | |
| self.messages = self.messages[-100:] | |
| self._refresh() | |
| def _refresh(self): | |
| if len(self.walker) >= self.max_lines: | |
| self.walker.pop(0) | |
| self.walker.append(urwid.Text(self.messages[-1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment