Skip to content
Snippets Groups Projects

GDP 4.2.10 - Adding Debug mode to GUI.py to run individual modules

Merged mhby1g21 requested to merge GDP-4.2.10 into master
6 files
+ 256
139
Compare changes
  • Side-by-side
  • Inline
Files
6
import tkinter as tk
from tkinter import ttk, messagebox
# tabs/config_tab.py
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QMessageBox
from PyQt6.QtGui import QTextCharFormat, QColor, QTextCursor
from utils.qt_widgets import create_group_with_text, create_button_layout
import os
class ConfigTab:
def __init__(self, notebook, config_reader):
self.tab = ttk.Frame(notebook)
notebook.add(self.tab, text='Configuration Check')
class ConfigTab(QWidget):
def __init__(self, config_reader):
super().__init__()
self.config_reader = config_reader
self.setup_ui()
def setup_ui(self):
# Main container with padding
main_frame = ttk.Frame(self.tab, padding="10")
main_frame.pack(fill=tk.BOTH, expand=True)
# Config section
config_frame = ttk.LabelFrame(main_frame, text="Config Values", padding="5")
config_frame.pack(fill=tk.X, pady=5)
self.config_text = tk.Text(config_frame, height=6, wrap=tk.WORD)
self.config_text.pack(fill=tk.X)
# Directory paths section
dir_frame = ttk.LabelFrame(main_frame, text="Directory Paths", padding="5")
dir_frame.pack(fill=tk.X, pady=5)
self.dir_text = tk.Text(dir_frame, height=8, wrap=tk.WORD)
self.dir_text.pack(fill=tk.X)
# File paths section
file_frame = ttk.LabelFrame(main_frame, text="File Paths", padding="5")
file_frame.pack(fill=tk.X, pady=5)
self.file_text = tk.Text(file_frame, height=5, wrap=tk.WORD)
self.file_text.pack(fill=tk.X)
# Path verification section
verify_frame = ttk.LabelFrame(main_frame, text="Path Verification", padding="5")
verify_frame.pack(fill=tk.X, pady=5)
self.verify_text = tk.Text(verify_frame, height=8, wrap=tk.WORD)
self.verify_text.pack(fill=tk.X)
# Buttons
button_frame = ttk.Frame(main_frame)
button_frame.pack(fill=tk.X, pady=5)
ttk.Button(
button_frame,
text="Refresh Config",
command=self.refresh_all
).pack(side=tk.LEFT, padx=5)
ttk.Button(
button_frame,
text="Verify Paths",
command=self.verify_paths
).pack(side=tk.LEFT, padx=5)
ttk.Button(
button_frame,
text="Save Debug Info",
command=self.save_debug_info
).pack(side=tk.RIGHT, padx=5)
def setup_ui(self):
main_layout = QVBoxLayout(self)
main_layout.setContentsMargins(10, 10, 10, 10)
# Create groups and text areas using the utility function
config_group, self.config_text = create_group_with_text("Config Values", 100)
dir_group, self.dir_text = create_group_with_text("Directory Paths", 120)
file_group, self.file_text = create_group_with_text("File Paths", 80)
verify_group, self.verify_text = create_group_with_text("Path Verification", 120)
# Add groups to layout
main_layout.addWidget(config_group)
main_layout.addWidget(dir_group)
main_layout.addWidget(file_group)
main_layout.addWidget(verify_group)
# Create buttons using the utility function
buttons = [
("Refresh Config", self.refresh_all, 'left'),
("Verify Paths", self.verify_paths, 'left'),
("Save Debug Info", self.save_debug_info, 'right')
]
button_layout = create_button_layout(*buttons)
main_layout.addLayout(button_layout)
# Initial display
self.refresh_all()
def refresh_all(self):
self.refresh_config_display()
self.refresh_directory_display()
self.refresh_file_display()
self.display_config()
self.display_directories()
self.display_files()
self.verify_paths()
def refresh_config_display(self):
self.config_text.delete(1.0, tk.END)
def display_config(self):
self.config_text.clear()
for key, value in self.config_reader.config.items():
self.config_text.insert(tk.END, f"{key} = {value}\n")
self.config_text.append(f"{key} = {value}")
def refresh_directory_display(self):
self.dir_text.delete(1.0, tk.END)
def display_directories(self):
self.dir_text.clear()
for key, path in self.config_reader.directories.items():
self.dir_text.insert(tk.END, f"{key}: {path}\n")
self.dir_text.append(f"{key}: {path}")
def refresh_file_display(self):
self.file_text.delete(1.0, tk.END)
def display_files(self):
self.file_text.clear()
for key, path in self.config_reader.file_paths.items():
self.file_text.insert(tk.END, f"{key}: {path}\n")
self.file_text.append(f"{key}: {path}")
def verify_paths(self):
self.verify_text.delete(1.0, tk.END)
self.verify_text.clear()
# Create formats for colored text
green_format = QTextCharFormat()
green_format.setForeground(QColor("green"))
red_format = QTextCharFormat()
red_format.setForeground(QColor("red"))
# Verify directories
self.verify_text.insert(tk.END, "Directory Verification:\n")
self.verify_text.append("Directory Verification:")
for key, path in self.config_reader.directories.items():
exists = os.path.exists(path)
status = "✓ exists" if exists else "✗ missing"
color = "green" if exists else "red"
self.verify_text.insert(tk.END, f"{key}: {status}\n", color)
self.verify_text.insert(tk.END, "\nFile Verification:\n")
cursor = self.verify_text.textCursor()
cursor.movePosition(QTextCursor.MoveOperation.End)
self.verify_text.setTextCursor(cursor)
self.verify_text.insertPlainText(f"{key}: ")
self.verify_text.setCurrentCharFormat(green_format if exists else red_format)
self.verify_text.insertPlainText(f"{status}\n")
self.verify_text.setCurrentCharFormat(QTextCharFormat())
self.verify_text.append("\nFile Verification:")
for key, path in self.config_reader.file_paths.items():
exists = os.path.exists(path)
status = "✓ exists" if exists else "✗ missing"
color = "green" if exists else "red"
self.verify_text.insert(tk.END, f"{key}: {status}\n", color)
# Add tags for colors
self.verify_text.tag_config("green", foreground="green")
self.verify_text.tag_config("red", foreground="red")
cursor = self.verify_text.textCursor()
cursor.movePosition(QTextCursor.MoveOperation.End)
self.verify_text.setTextCursor(cursor)
self.verify_text.insertPlainText(f"{key}: ")
self.verify_text.setCurrentCharFormat(green_format if exists else red_format)
self.verify_text.insertPlainText(f"{status}\n")
def save_debug_info(self):
debug_info = "=== Pipeline Debug Information ===\n\n"
@@ -130,13 +110,13 @@ class ConfigTab:
status = "exists" if exists else "missing"
debug_info += f"{key}: {path} ({status})\n"
# Save to debug tool directory
try:
debug_path = os.path.join(self.config_reader.directories['debugDir'],
"pipeline_debug_info.txt")
"debug_config_info.txt")
with open(debug_path, "w") as f:
f.write(debug_info)
messagebox.showinfo("Success",
f"Debug information saved to:\n{debug_path}")
QMessageBox.information(self, "Success",
f"Debug information saved to:\n{debug_path}")
except Exception as e:
messagebox.showerror("Error", f"Failed to save debug info: {str(e)}")
\ No newline at end of file
QMessageBox.critical(self, "Error",
f"Failed to save debug info: {str(e)}")
\ No newline at end of file
Loading