martedì 21 agosto 2012

Esempio GUI con PyQt

Un esempio di GUI mediante PyQT





import sys
from PyQt4 import QtGui, QtCore

app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()

widget.setGeometry(200, 100, 220, 120)
widget.setWindowTitle('Slider Example')

label1 = QtGui.QLabel("Valore:      ", widget)
label1.move(80, 50)

slider = QtGui.QSlider(QtCore.Qt.Horizontal, widget)
slider.setGeometry(10, 10, 200, 30)
slider.setFocusPolicy(QtCore.Qt.NoFocus)

pb = QtGui.QProgressBar(widget)
pb.setGeometry(10, 70, 215, 20)

def getValue(value):
    label1.setText("Valore: "+str(value))
    pb.setValue(value)


   
widget.connect(slider, QtCore.SIGNAL('valueChanged(int)'), getValue)



widget.show()
sys.exit(app.exec_())