mirror of
https://github.com/curly60e/pyblock.git
synced 2026-08-17 13:07:17 +02:00
New pybitblock/tui/ package providing a modern terminal UI: Structure: tui/app.py - Main Textual App with CSS layout, auto-refresh tui/screens/ - Screen classes (main_menu.py with keybindings) tui/widgets/ - StatusBar widget with reactive block/price data tui/workers/ - Async data fetchers (block height, price, fees, mempool) Features: - Persistent status bar with mode, block height, BTC price - Side panel showing live fee estimates (fast/medium/slow) - Keyboard navigation (A=PyBLOCK, B=Bitcoin, L=Lightning, etc.) - Auto-refresh every 30 seconds via async workers - Dark theme with Bitcoin-inspired color scheme - CSS-based responsive layout Launch: python3 PyBlock.py --tui Fallback: python3 PyBlock.py (original CLI mode) Added textual>=0.89 to requirements.txt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""Persistent status bar widget showing mode, block height, and BTC price."""
|
|
|
|
from textual.widgets import Static
|
|
from textual.reactive import reactive
|
|
from rich.text import Text
|
|
|
|
|
|
class StatusBar(Static):
|
|
"""Top status bar with live-updating Bitcoin data."""
|
|
|
|
mode = reactive("lite")
|
|
block_height = reactive("---")
|
|
btc_price = reactive("---")
|
|
node_alias = reactive("")
|
|
|
|
MODE_LABELS = {
|
|
"local": ("Bitcoin + Lightning", "green"),
|
|
"remote": ("Remote Node", "cyan"),
|
|
"onchain_only": ("Bitcoin Only", "yellow"),
|
|
"lite": ("Lite Mode", "yellow"),
|
|
}
|
|
|
|
def render(self):
|
|
label, color = self.MODE_LABELS.get(self.mode, (self.mode, "white"))
|
|
|
|
text = Text()
|
|
text.append(f" {label} ", style=f"bold {color} on rgb(30,30,30)")
|
|
text.append(" ", style="on rgb(20,20,20)")
|
|
text.append(f" Block: ", style="dim on rgb(20,20,20)")
|
|
text.append(f"{self.block_height} ", style="bold white on rgb(20,20,20)")
|
|
text.append(" ", style="on rgb(20,20,20)")
|
|
text.append(f" BTC: ", style="dim on rgb(20,20,20)")
|
|
text.append(f"${self.btc_price} ", style="bold green on rgb(20,20,20)")
|
|
if self.node_alias:
|
|
text.append(" ", style="on rgb(20,20,20)")
|
|
text.append(f" Node: {self.node_alias} ", style="bold yellow on rgb(20,20,20)")
|
|
|
|
return text
|