本文整理汇总了Python中PyQt4.QtGui.QDoubleSpinBox.setPrefix方法的典型用法代码示例。如果您正苦于以下问题:Python QDoubleSpinBox.setPrefix方法的具体用法?Python QDoubleSpinBox.setPrefix怎么用?Python QDoubleSpinBox.setPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QDoubleSpinBox
的用法示例。
在下文中一共展示了QDoubleSpinBox.setPrefix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Form
# 需要导入模块: from PyQt4.QtGui import QDoubleSpinBox [as 别名]
# 或者: from PyQt4.QtGui.QDoubleSpinBox import setPrefix [as 别名]
class Form(QDialog):
def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.label_amount = QLabel('Amount')
self.spin_amount = QDoubleSpinBox()
self.spin_amount.setRange(0, 10000000000)
self.spin_amount.setPrefix('Rp. ')
self.spin_amount.setSingleStep(100000)
self.label_rate = QLabel('Rate')
self.spin_rate = QDoubleSpinBox()
self.spin_rate.setSuffix(' %')
self.spin_rate.setSingleStep(0.1)
self.spin_rate.setRange(0, 100)
self.label_year = QLabel('Years')
self.spin_year = QSpinBox()
self.spin_year.setSuffix(' year')
self.spin_year.setSingleStep(1)
self.spin_year.setRange(0, 1000)
self.spin_year.setValue(1)
self.label_total_ = QLabel('Total')
self.label_total = QLabel('Rp. 0.00')
grid = QGridLayout()
grid.addWidget(self.label_amount, 0, 0)
grid.addWidget(self.spin_amount, 0, 1)
grid.addWidget(self.label_rate, 1, 0)
grid.addWidget(self.spin_rate, 1, 1)
grid.addWidget(self.label_year, 2, 0)
grid.addWidget(self.spin_year, 2, 1)
grid.addWidget(self.label_total_, 3, 0)
grid.addWidget(self.label_total, 3, 1)
self.setLayout(grid)
self.connect(self.spin_amount, SIGNAL('valueChanged(double)'), self.update_ui)
self.connect(self.spin_rate, SIGNAL('valueChanged(double)'), self.update_ui)
self.connect(self.spin_year, SIGNAL('valueChanged(int)'), self.update_ui)
self.setWindowTitle('Interest')
def update_ui(self):
amount = self.spin_amount.value()
rate = self.spin_rate.value()
year = self.spin_year.value()
total = amount * (1 + rate / 100.0) ** year
self.label_total.setText('Rp. %.2f' % total)