Skip to content

Commit

Permalink
block the user from saving to invalid filenames on the data widget
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiCheng45 committed Jan 7, 2025
1 parent 2def3a1 commit 012b9de
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MDANSE_GUI/Src/MDANSE_GUI/Tabs/Visualisers/DataWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def make_bottom_bar(self):
self.layout().addLayout(layout)
layout.addWidget(QLabel("Output file:"))
self._output_widget = QLineEdit("", self)
self._output_widget.textChanged.connect(self.check_file_writable)
layout.addWidget(self._output_widget)
self._browse_button = QPushButton("Browse", self)
self._browse_button.clicked.connect(self.output_file_dialog)
Expand All @@ -130,6 +131,15 @@ def make_bottom_bar(self):
self._output_button.clicked.connect(self.save_to_file)
layout.addWidget(self._output_button)

@Slot()
def check_file_writable(self):
if PLATFORM.is_file_writable(self._output_widget.text()):
self._output_button.setEnabled(True)
self._output_widget.setStyleSheet("")
else:
self._output_button.setEnabled(False)
self._output_widget.setStyleSheet("color: red;")

@Slot()
def output_file_dialog(self):
new_value = QFileDialog.getSaveFileName(
Expand Down

0 comments on commit 012b9de

Please sign in to comment.