本文整理匯總了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)