From c9e2d0126af09f3332cbce682635843c9df4a6b0 Mon Sep 17 00:00:00 2001 From: Grabt234 Date: Mon, 7 Oct 2024 17:43:05 +0200 Subject: [PATCH] Fix: For tabs --- viewer.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/viewer.py b/viewer.py index 55c8556..2ed8a36 100644 --- a/viewer.py +++ b/viewer.py @@ -94,6 +94,11 @@ def update_images(self): msg = self.show_popup("Loading", False) self.Sxx = {} + + if self.num_channels: + for i in range(self.num_channels): + self.remove_plot_tab(i) + for i in range(self.num_channels): self.add_plot_tab(i) self.generate_spectrogram_data(i) @@ -133,23 +138,23 @@ def update_spectrum_image(self, channel_index, spectrum_column_index): self.channel_plots[channel_index].spectrum_axes.set_ylabel('Intensity [Arb dB]') self.channel_plots[channel_index].spectrum_axes.set_title(f'Spectrum Sample at Time of {slice_time} Seconds of \n ' + self.file_path_label.text()) - self.set_spectrum_axes_limits() + self.set_spectrum_axes_limits(channel_index) # Update the column plot canvas self.channel_plots[channel_index].spectrum_canvas.draw() - def set_spectrum_axes_limits(self): + def set_spectrum_axes_limits(self,channel_index): selected_spectrum_mode = self.spectrum_mode.getInputText() if selected_spectrum_mode == "Amplitude [dB]": - self.channel_plots[0].spectrum_axes.set_ylim([-60,60]) + self.channel_plots[channel_index].spectrum_axes.set_ylim([-60,60]) elif selected_spectrum_mode == "Amplitude [lin]": - self.channel_plots[0].spectrum_axes.set_ylim([-1,50]) + self.channel_plots[channel_index].spectrum_axes.set_ylim([-1,50]) elif selected_spectrum_mode == "Phase [Rad]": - self.channel_plots[0].spectrum_axes.set_ylim([-1.1*np.pi,1.1*np.pi]) + self.channel_plots[channel_index].spectrum_axes.set_ylim([-1.1*np.pi,1.1*np.pi]) elif selected_spectrum_mode == "Phase [Deg]": - self.channel_plots[0].spectrum_axes.set_ylim([-185,185]) + self.channel_plots[channel_index].spectrum_axes.set_ylim([-185,185]) def on_click(self, event): @@ -170,11 +175,6 @@ def on_click(self, event): def load_file(self): - # Clear current tabs if they exist - if self.num_channels: - for i in range(self.num_channels): - self.remove_plot_tab(i) - # Open a file dialog to let the user select a file file_path, _ = QFileDialog.getOpenFileName(self, "Select File", "", "*.wav")