diff --git a/frappy/gui/modulewidget.py b/frappy/gui/modulewidget.py index 52f4b91..cbaacba 100644 --- a/frappy/gui/modulewidget.py +++ b/frappy/gui/modulewidget.py @@ -24,9 +24,9 @@ from frappy.gui.qt import QColor, QDialog, QHBoxLayout, QIcon, QLabel, \ QLineEdit, QMessageBox, QPropertyAnimation, QPushButton, Qt, QToolButton, \ QWidget, pyqtProperty, pyqtSignal +from frappy.gui.inputwidgets import get_input_widget from frappy.gui.util import Colors, loadUi from frappy.gui.valuewidgets import get_widget -from frappy.gui.inputwidgets import get_input_widget class CommandDialog(QDialog): @@ -54,7 +54,11 @@ class CommandDialog(QDialog): self.resize(self.sizeHint()) def get_value(self): - return True, self.widgets[0].get_value() + try: + return self.widgets[0].get_value() + except Exception as e: + QMessageBox.warning(self.parent(), 'Operation failed', str(e)) + return None def exec(self): if super().exec(): @@ -95,8 +99,9 @@ class CommandButton(QPushButton): if self._argintype: dlg = CommandDialog(self._cmdname, self._argintype) args = dlg.exec() - if args: # not 'Cancel' clicked - self._cb(self._cmdname, args[1]) + if args is not None: + # no errors when converting value and 'Cancel' wasn't clicked + self._cb(self._cmdname, args) else: # no need for arguments self._cb(self._cmdname, None) @@ -442,8 +447,8 @@ class ModuleWidget(QWidget): self.paramDetails.emit(self._name, param) def _button_pressed(self, param): - target = self._paramInputs[param].get_input() try: + target = self._paramInputs[param].get_input() self._node.setParameter(self._name, param, target) except Exception as e: QMessageBox.warning(self.parent(), 'Operation failed', str(e))