MCPcopy Create free account
hub / github.com/Da1sypetals/SnapViewer / REPLPanel

Class REPLPanel

gui.py:304–494  ·  view source on GitHub ↗

REPL panel with input and scrollable output

Source from the content-addressed store, hash-verified

302
303
304class REPLPanel(ttk.Frame):
305 """REPL panel with input and scrollable output"""
306
307 REPL_HINT = (
308 "SQLite REPL - This is a SQLite database storing the allocation data.",
309 "Type `--help` to see available commands.",
310 "Type `--find <pattern>` to search messages.",
311 "Ctrl+D to quit application.",
312 )
313
314 def __init__(self, parent, args, palette: ColorPalette):
315 super().__init__(parent)
316 self.args = args
317 self.parent = parent
318 self.palette = palette
319 self.setup_ui()
320
321 def setup_ui(self):
322 """Setup the UI components"""
323 # Configure padding
324 self.configure(padding="20")
325
326 # Configure fonts - try to use the font file if available
327 font_path = os.path.join(os.path.dirname(__file__), "assets", "JetBrainsMono-Medium.ttf")
328 try:
329 if os.path.exists(font_path):
330 # Register the font with tkinter using the low-level tk interface
331 self.winfo_toplevel().tk.call(
332 "font", "create", "JetBrainsMonoCustom", "-family", "JetBrains Mono", "-size", "14"
333 )
334 # Try to load the actual font file using platform-specific methods
335 if platform.system() == "Windows":
336 try:
337 # Load font temporarily for this session
338 gdi32 = ctypes.windll.gdi32
339 gdi32.AddFontResourceW.argtypes = [wintypes.LPCWSTR]
340 gdi32.AddFontResourceW.restype = ctypes.c_int
341 result = gdi32.AddFontResourceW(font_path)
342 if result:
343 print(f"Successfully loaded JetBrains Mono font from {font_path}")
344 font_family = "JetBrains Mono"
345 else:
346 raise Exception("AddFontResourceW failed")
347 except Exception as e:
348 print(f"Could not load font via Windows API: {e}")
349 font_family = "Consolas"
350 else:
351 # For Unix-like systems, we can't load fonts at runtime easily
352 # Just use the family name and hope it's installed
353 font_family = "JetBrains Mono"
354 else:
355 raise FileNotFoundError("Font file not found")
356 except Exception as e:
357 print(f"Font loading failed: {e}")
358 # Fallback to family name (works if font is installed system-wide)
359 try:
360 test_font = font.Font(family="JetBrains Mono", size=12)
361 if "JetBrains Mono" in test_font.actual("family"):

Callers 1

setup_uiMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected