diff --git a/python/plugins/processing/gui/NumberInputDialog.py b/python/plugins/processing/gui/NumberInputDialog.py
index f765688721e..34474f864e9 100644
--- a/python/plugins/processing/gui/NumberInputDialog.py
+++ b/python/plugins/processing/gui/NumberInputDialog.py
@@ -37,7 +37,7 @@ from processing.ui.ui_DlgNumberInput import Ui_DlgNumberInput
class NumberInputDialog(QDialog, Ui_DlgNumberInput):
- def __init__(self):
+ def __init__(self, isInteger):
QDialog.__init__(self)
self.setupUi(self)
@@ -48,6 +48,10 @@ class NumberInputDialog(QDialog, Ui_DlgNumberInput):
self.treeValues.doubleClicked.connect(self.addValue)
self.value = None
+ self.isInteger = isInteger
+
+ if not self.isInteger:
+ self.lblWarning.hide()
self.fillTree()
@@ -123,6 +127,8 @@ class NumberInputDialog(QDialog, Ui_DlgNumberInput):
def accept(self):
try:
self.value = float(eval(str(self.leFormula.text())))
+ if self.isInteger:
+ self.value = int(round(self.value))
QDialog.accept(self)
except:
QMessageBox.critical(self, self.tr('Wrong expression'),
diff --git a/python/plugins/processing/gui/NumberInputPanel.py b/python/plugins/processing/gui/NumberInputPanel.py
index 7e813431c10..0765d21c773 100644
--- a/python/plugins/processing/gui/NumberInputPanel.py
+++ b/python/plugins/processing/gui/NumberInputPanel.py
@@ -25,52 +25,38 @@ __copyright__ = '(C) 2012, Victor Olaya'
__revision__ = '$Format:%H$'
-from PyQt4 import QtGui
+from PyQt4.QtGui import *
from processing.gui.NumberInputDialog import NumberInputDialog
+from processing.ui.ui_widgetNumberInput import Ui_widgetNumberInput
-class NumberInputPanel(QtGui.QWidget):
+class NumberInputPanel(QWidget, Ui_widgetNumberInput):
def __init__(self, number, minimum, maximum, isInteger):
- super(NumberInputPanel, self).__init__(None)
- self.horizontalLayout = QtGui.QHBoxLayout(self)
- self.horizontalLayout.setSpacing(2)
- self.horizontalLayout.setMargin(0)
+ QDialog.__init__(self)
+ self.setupUi(self)
+
self.isInteger = isInteger
- if isInteger:
- self.spin = QtGui.QSpinBox()
+ if self.isInteger:
+ self.spnValue.setDecimals(0)
if maximum:
- self.spin.setMaximum(maximum)
+ self.spnValue.setMaximum(maximum)
else:
- self.spin.setMaximum(99999999)
+ self.spnValue.setMaximum(99999999)
if minimum:
- self.spin.setMinimum(minimum)
+ self.spnValue.setMinimum(minimum)
else:
- self.spin.setMinimum(-99999999)
- self.spin.setValue(number)
- self.horizontalLayout.addWidget(self.spin)
- self.setLayout(self.horizontalLayout)
- else:
- self.text = QtGui.QLineEdit()
- self.text.setText(str(number))
- self.text.setSizePolicy(QtGui.QSizePolicy.Expanding,
- QtGui.QSizePolicy.Expanding)
- self.horizontalLayout.addWidget(self.text)
- self.pushButton = QtGui.QPushButton()
- self.pushButton.setText('...')
- self.pushButton.clicked.connect(self.showNumberInputDialog)
- self.horizontalLayout.addWidget(self.pushButton)
- self.setLayout(self.horizontalLayout)
+ self.spnValue.setMinimum(-99999999)
+
+ self.spnValue.setValue(float(number))
+
+ self.btnCalc.clicked.connect(self.showNumberInputDialog)
def showNumberInputDialog(self):
- pass
- dlg = NumberInputDialog()
+ dlg = NumberInputDialog(self.isInteger)
dlg.exec_()
if dlg.value is not None:
- self.text.setText(str(dlg.value))
+ self.spnValue.setValue(dlg.value)
def getValue(self):
- if self.isInteger:
- return self.spin.value()
- else:
- return self.text.text()
+ return self.spnValue.value()
diff --git a/python/plugins/processing/ui/DlgNumberInput.ui b/python/plugins/processing/ui/DlgNumberInput.ui
index ef639843559..15514444ca9 100644
--- a/python/plugins/processing/ui/DlgNumberInput.ui
+++ b/python/plugins/processing/ui/DlgNumberInput.ui
@@ -32,8 +32,20 @@
-
- Enter expression in the text field.
-Double click on elements in the tree to add their values to the expression.
+ <html><head/><body><p>Enter expression in the text field. Double click on elements in the tree to add their values to the expression.</p></body></html>
+
+
+ true
+
+
+
+ -
+
+
+ <html><head/><body><p><span style=" font-weight:600;">Warning</span>: if expression result is float value, but integer required, result will be rounded to integer.</p></body></html>
+
+
+ true
diff --git a/python/plugins/processing/ui/ui_widgetNumberInput.py b/python/plugins/processing/ui/ui_widgetNumberInput.py
new file mode 100644
index 00000000000..8424c649661
--- /dev/null
+++ b/python/plugins/processing/ui/ui_widgetNumberInput.py
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+
+# Form implementation generated from reading ui file 'python/plugins/processing/ui/widgetNumberInput.ui'
+#
+# Created: Wed Oct 9 19:20:54 2013
+# by: PyQt4 UI code generator 4.9.1
+#
+# WARNING! All changes made in this file will be lost!
+
+from PyQt4 import QtCore, QtGui
+
+try:
+ _fromUtf8 = QtCore.QString.fromUtf8
+except AttributeError:
+ _fromUtf8 = lambda s: s
+
+class Ui_widgetNumberInput(object):
+ def setupUi(self, widgetNumberInput):
+ widgetNumberInput.setObjectName(_fromUtf8("widgetNumberInput"))
+ widgetNumberInput.resize(189, 28)
+ self.horizontalLayout_2 = QtGui.QHBoxLayout(widgetNumberInput)
+ self.horizontalLayout_2.setContentsMargins(0, 0, 0, 2)
+ self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
+ self.horizontalLayout = QtGui.QHBoxLayout()
+ self.horizontalLayout.setSpacing(2)
+ self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
+ self.spnValue = QtGui.QDoubleSpinBox(widgetNumberInput)
+ self.spnValue.setDecimals(6)
+ self.spnValue.setMinimum(-100000000.0)
+ self.spnValue.setMaximum(100000000.0)
+ self.spnValue.setObjectName(_fromUtf8("spnValue"))
+ self.horizontalLayout.addWidget(self.spnValue)
+ self.btnCalc = QtGui.QToolButton(widgetNumberInput)
+ self.btnCalc.setObjectName(_fromUtf8("btnCalc"))
+ self.horizontalLayout.addWidget(self.btnCalc)
+ self.horizontalLayout_2.addLayout(self.horizontalLayout)
+
+ self.retranslateUi(widgetNumberInput)
+ QtCore.QMetaObject.connectSlotsByName(widgetNumberInput)
+
+ def retranslateUi(self, widgetNumberInput):
+ widgetNumberInput.setWindowTitle(QtGui.QApplication.translate("widgetNumberInput", "Form", None, QtGui.QApplication.UnicodeUTF8))
+ self.btnCalc.setToolTip(QtGui.QApplication.translate("widgetNumberInput", "Open number input dialog", None, QtGui.QApplication.UnicodeUTF8))
+ self.btnCalc.setText(QtGui.QApplication.translate("widgetNumberInput", "...", None, QtGui.QApplication.UnicodeUTF8))
+
diff --git a/python/plugins/processing/ui/widgetNumberInput.ui b/python/plugins/processing/ui/widgetNumberInput.ui
new file mode 100644
index 00000000000..cbfe0668b4b
--- /dev/null
+++ b/python/plugins/processing/ui/widgetNumberInput.ui
@@ -0,0 +1,63 @@
+
+
+ widgetNumberInput
+
+
+
+ 0
+ 0
+ 189
+ 28
+
+
+
+ Form
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 2
+
+ -
+
+
+ 2
+
+
-
+
+
+ 6
+
+
+ -99999999.999999001622200
+
+
+ 99999999.999999001622200
+
+
+
+ -
+
+
+ Open number input dialog
+
+
+ ...
+
+
+
+
+
+
+
+
+
+