diff --git a/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py b/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py index 631a530afe785904b2bb51f56b57a9a791e4c0cb..e88e538644785cb81dfcc1e1969761f2add079f2 100644 --- a/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py +++ b/src/View/Results/CustomPlot/CustomPlotValuesSelectionDialog.py @@ -45,7 +45,6 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog): self.setup_check_boxs() self.value = None - self.export_to_csv = False def setup_radio_buttons(self): self._radio = [] @@ -96,6 +95,5 @@ class CustomPlotValuesSelectionDialog(PamhyrDialog): ) self.value = x, y - self.export_to_csv = self.find(QCheckBox, - "checkBox_export").isChecked() + super().accept() diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py index 325b16e3d750568bf7eda18b8e28f2cabf523110..b1872102f8b16ca929601e39a205cdc9bb5601cc 100644 --- a/src/View/Results/Window.py +++ b/src/View/Results/Window.py @@ -310,8 +310,8 @@ class ResultsWindow(PamhyrWindow): actions = { "action_reload": self._reload, "action_add": self._add_custom_plot, - # "action_export": self.export, - "action_export": self.export_current, + "action_export": self._export, + # "action_export": self.export_current, } for action in actions: @@ -491,17 +491,12 @@ class ResultsWindow(PamhyrWindow): dlg = CustomPlotValuesSelectionDialog(parent=self) if dlg.exec(): x, y = dlg.value - export = dlg.export_to_csv - self.create_new_tab_custom_plot(x, y, export) + self.create_new_tab_custom_plot(x, y) - def create_new_tab_custom_plot(self, x: str, y: list, export: bool): + def create_new_tab_custom_plot(self, x: str, y: list): name = f"{x}: {','.join(y)}" wname = f"tab_custom_{x}_{y}" - if export: - self.export(x, y) - return - tab_widget = self.find(QTabWidget, f"tabWidget") # This plot already exists @@ -590,7 +585,13 @@ class ResultsWindow(PamhyrWindow): self._button_last.setEnabled(True) self._button_play.setIcon(self._icon_start) - def export(self, x: str, y: list): + def _export(self): + + dlg = CustomPlotValuesSelectionDialog(parent=self) + if dlg.exec(): + x, y = dlg.value + else: + return logger.debug( "Export custom plot for: " + @@ -741,8 +742,9 @@ class ResultsWindow(PamhyrWindow): reach = self._results.river.reachs[self._get_current_reach()] profile = reach.profile(profile) ts = list(self._results.get("timestamps")) + ts.sort() my_dict = {} - my_dict["time"] = ts.sort() + my_dict["time"] = ts z = profile.get_key("Z") q = profile.get_key("Q") if "elevation" in y: diff --git a/src/View/ui/CustomPlotValuesSelectionDialog.ui b/src/View/ui/CustomPlotValuesSelectionDialog.ui index fb9334d13dedbda6deefae1c2f57dd377f566a9e..f7daec375828061a2af5c6aed5d9df0ca1b18a15 100644 --- a/src/View/ui/CustomPlotValuesSelectionDialog.ui +++ b/src/View/ui/CustomPlotValuesSelectionDialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>414</width> - <height>81</height> + <height>70</height> </rect> </property> <property name="windowTitle"> @@ -44,33 +44,15 @@ </widget> </item> <item row="1" column="0"> - <widget class="Line" name="line"> + <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> </widget> </item> - <item row="4" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QCheckBox" name="checkBox_export"> - <property name="text"> - <string>Export to CSV</string> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </item> </layout> </widget> <resources/> diff --git a/src/View/ui/Results.ui b/src/View/ui/Results.ui index 1b4a93ee9247d0473c9b479b3ab7f6a19c0ee37b..e92bdab43aa2bd8be8990d5e165be34f81376aab 100644 --- a/src/View/ui/Results.ui +++ b/src/View/ui/Results.ui @@ -262,7 +262,7 @@ <string>Export</string> </property> <property name="toolTip"> - <string>Export raw data</string> + <string>Export data as CSV</string> </property> <property name="shortcut"> <string>Ctrl+E</string>