-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_launcher.py
More file actions
executable file
·31 lines (26 loc) · 952 Bytes
/
debug_launcher.py
File metadata and controls
executable file
·31 lines (26 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
"""
Debug launcher for serial_gui.py
Sets a breakpoint at the process_text method
"""
import pdb
import tkinter as tk
import importlib
import serial_gui
import types
# Patch the process_text method to include a breakpoint
original_process_text = serial_gui.AnsiColorizer.process_text
def patched_process_text(self, text):
# This is where the debugger will stop
breakpoint() # Python 3.7+ breakpoint() function
return original_process_text(self, text)
# Apply the monkey patch
serial_gui.AnsiColorizer.process_text = patched_process_text
# Start the application
if __name__ == "__main__":
print("Starting serial_gui in debug mode with breakpoint at process_text()")
print("When text with ANSI codes is received, the debugger will pause execution")
print("Use 'n' to step to next line, 'c' to continue, 'q' to quit debugger")
root = tk.Tk()
app = serial_gui.SerialGUI(root)
root.mainloop()