本文整理汇总了Python中PyQt4.QtGui.QDoubleValidator方法的典型用法代码示例。如果您正苦于以下问题:Python QtGui.QDoubleValidator方法的具体用法?Python QtGui.QDoubleValidator怎么用?Python QtGui.QDoubleValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui
的用法示例。
在下文中一共展示了QtGui.QDoubleValidator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QDoubleValidator [as 别名]
def __init__(self, *args, **kwargs):
super(Calculator, self).__init__(*args, **kwargs)
# Single-inheritence approach: http://goo.gl/WNiHc
# Calculator class only inherits from QWidget
# A specific member attribute self.ui contains all
# widgets set up in the designer.
self.ui = Ui_Calculator()
self.ui.setupUi(self)
self.ui.calcButton = QtGui.QPushButton("Calculate")
self.ui.horizontalLayout_2.addWidget(self.ui.calcButton)
# Create a validator for each QLineEdit that only
# allows a user to enter floats: 123.123
self.ui.inputA.setValidator(QtGui.QDoubleValidator())
self.ui.inputB.setValidator(QtGui.QDoubleValidator())
# instead of using the stock operator values set in the
# ui file, lets set the box to match our class attribute
self.ui.operatorBox.clear()
self.ui.operatorBox.addItems(self.OPS.keys())
self.ui.clearButton.clicked.connect(self.clear)
self.ui.calcButton.clicked.connect(self.calc)
示例2: init_gui
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QDoubleValidator [as 别名]
def init_gui(self):
"""
Initializes form widgets
"""
validator = QtGui.QDoubleValidator()
self.edtMinVal.setValidator(validator)
self.edtMaxVal.setValidator(validator)
self.edtMinVal.setText(str(self._min_val))
self.edtMaxVal.setText(str(self._max_val))
self.edtMinVal.setEnabled(not self.in_db)
self.edtMaxVal.setEnabled(not self.in_db)
self.sbPrecision.setEnabled(not self.in_db)
self.sbScale.setEnabled(not self.in_db)
self.sbPrecision.setValue(self._precision)
self.sbScale.setValue(self._scale)
示例3: __init__
# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QDoubleValidator [as 别名]
def __init__(self, *args, **kwargs):
super(Calculator, self).__init__(*args, **kwargs)
# Single-inheritence approach: http://goo.gl/WNiHc
# Calculator class only inherits from QWidget
# A specific member attribute self.ui contains all
# widgets set up in the designer.
self.ui = Ui_Calculator()
self.ui.setupUi(self)
# Create a validator for each QLineEdit that only
# allows a user to enter floats: 123.123
self.ui.inputA.setValidator(QtGui.QDoubleValidator())
self.ui.inputB.setValidator(QtGui.QDoubleValidator())
# instead of using the stock operator values set in the
# ui file, lets set the box to match our class attribute
self.ui.operatorBox.clear()
self.ui.operatorBox.addItems(self.OPS.keys())
self.ui.clearButton.clicked.connect(self.clear)
# every time the text is edited in either input field,
# calculate the result live
self.ui.inputA.textEdited.connect(self.calc)
self.ui.inputB.textEdited.connect(self.calc)
# also when the operator box is changed
self.ui.operatorBox.currentIndexChanged.connect(self.calc)