(self, folder, name, run_mode, golds_folder=None)
| 56 | |
| 57 | class PolledPlotApp(tk.Tk): |
| 58 | def __init__(self, folder, name, run_mode, golds_folder=None): |
| 59 | super().__init__() |
| 60 | self.title("Polled CSV Plotter") |
| 61 | self.geometry("900x650") |
| 62 | |
| 63 | # Persist per-series visibility across Y selections |
| 64 | self.visible = {} # {series_label: bool} |
| 65 | # Persist per-series style for legend proxies |
| 66 | self.styles = {} # {series_label: dict(color=..., linestyle=..., marker=...)} |
| 67 | |
| 68 | # Load CSVs according to run mode |
| 69 | self.dfs = self.load_csvs(folder, name, golds_folder, run_mode) |
| 70 | if not self.dfs: |
| 71 | messagebox.showerror("Error", "No valid CSV files found for the given inputs.") |
| 72 | self.destroy() |
| 73 | return |
| 74 | |
| 75 | # Initialize columns/UI |
| 76 | cols = list(self.dfs[0][1].columns) |
| 77 | if len(cols) < 2: |
| 78 | messagebox.showerror("Error", "CSV files must have at least two columns.") |
| 79 | self.destroy() |
| 80 | return |
| 81 | |
| 82 | self.x_col = cols[0] |
| 83 | self.y_choices = cols[1:] |
| 84 | |
| 85 | ctrl = ttk.Frame(self) |
| 86 | ctrl.pack(side=tk.TOP, fill=tk.X, padx=8, pady=8) |
| 87 | |
| 88 | ttk.Label(ctrl, text="X-axis:").pack(side=tk.LEFT) |
| 89 | ttk.Label(ctrl, text=self.x_col, width=15).pack(side=tk.LEFT, padx=(0, 20)) |
| 90 | ttk.Label(ctrl, text="Y-axis:").pack(side=tk.LEFT) |
| 91 | |
| 92 | self.y_combo = AutocompleteCombobox(ctrl, state="normal", width=50) |
| 93 | self.y_combo.set_completion_list(self.y_choices) |
| 94 | self.y_combo.set(self.y_choices[0]) |
| 95 | self.y_combo.pack(side=tk.LEFT, padx=(0, 10)) |
| 96 | self.y_combo.bind("<<ComboboxSelected>>", self.on_select) |
| 97 | |
| 98 | ttk.Button(ctrl, text="Exit", command=self.destroy).pack(side=tk.RIGHT) |
| 99 | |
| 100 | # Matplotlib figure/canvas/toolbar |
| 101 | self.fig = Figure(figsize=(6, 4)) |
| 102 | self.ax = self.fig.add_subplot(111) |
| 103 | |
| 104 | self.canvas = FigureCanvasTkAgg(self.fig, master=self) |
| 105 | self.canvas.draw() |
| 106 | self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1) |
| 107 | |
| 108 | self.toolbar = NavigationToolbar2Tk(self.canvas, self) |
| 109 | self.toolbar.update() |
| 110 | self.toolbar.pack(side=tk.TOP, fill=tk.X) |
| 111 | |
| 112 | # One pick handler for the lifetime of the app |
| 113 | self.fig.canvas.mpl_connect("pick_event", self.on_pick) |
| 114 | |
| 115 | # Initial draw |
no test coverage detected