标签:io ar sp log on c amp line ad
# -*- coding: cp936 -*-
import sys
from PyQt4 import QtCore, QtGui
class MyDialog(QtGui.QDialog):
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.quit = QtGui.QPushButton("Quit")
self.change = QtGui.QPushButton("Change")
self.change.setEnabled(False)
# funny widget
self.lcd = QtGui.QLCDNumber(2)
self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
self.slider.setRange(0, 99)
self.slider.setValue(0)
self.lineEdit = QtGui.QLineEdit()
self.connect(self.quit, QtCore.SIGNAL("clicked()"),
QtGui.qApp, QtCore.SLOT("quit()"))
self.connect(self.lineEdit, QtCore.SIGNAL("textChanged(const QString&)"),
self.enableChangeButton)
self.connect(self.slider, QtCore.SIGNAL("valueChanged(int)"),
self.SliderChange)
self.connect(self.change, QtCore.SIGNAL("clicked()"),
self.Change)
self.rightLayout = QtGui.QVBoxLayout()
self.rightLayout.addWidget(self.lineEdit)
self.rightLayout.addWidget(self.change)
self.leftLayout = QtGui.QVBoxLayout()
self.leftLayout.addWidget(self.lcd)
self.leftLayout.addWidget(self.slider)
self.layout = QtGui.QHBoxLayout()
self.layout.addWidget(self.quit)
self.layout.addLayout(self.leftLayout)
self.layout.addLayout(self.rightLayout)
self.setLayout(self.layout);
def enableChangeButton(self, text):
self.change.setEnabled(text.isEmpty() == False)#重点
def Change(self):
value = int(self.lineEdit.text())
self.lcd.display(value)
self.slider.setValue(value)
def SliderChange(self):
value = self.slider.value()
self.lcd.display(value)
self.lineEdit.setText(str(value))
app = QtGui.QApplication(sys.argv)
dialog = MyDialog()
dialog.show()
sys.exit(app.exec_())
标签:io ar sp log on c amp line ad
原文地址:http://www.cnblogs.com/mhxy13867806343/p/3972858.html