alberthrocks

testcase for silly qt qslider event handling

Jan 26th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | None | 0 0
  1. import sys
  2. from PyQt4 import QtGui, QtCore
  3.  
  4. class Example(QtGui.QWidget):
  5.     def __init__(self):
  6.         super(Example, self).__init__()
  7.        
  8.         self.initUI()
  9.        
  10.     def initUI(self):
  11.         sld = QtGui.QSlider(QtCore.Qt.Horizontal, self)
  12.         sld.setFocusPolicy(QtCore.Qt.NoFocus)
  13.         sld.setGeometry(30, 40, 100, 30)
  14.         sld.setTracking(False)
  15.         sld.valueChanged[int].connect(self.changeValue)
  16.        
  17.         self.label = QtGui.QLabel(self)
  18.         self.label.setPixmap(QtGui.QPixmap('mute.png'))
  19.         self.label.setGeometry(160, 40, 80, 30)
  20.        
  21.         self.setGeometry(300, 300, 280, 170)
  22.         self.setWindowTitle('QtGui.QSlider')
  23.         self.show()
  24.        
  25.     def changeValue(self, value):
  26.         print "changeValue called"
  27.         confirm = QtGui.QMessageBox.question(self, "Save exam?",
  28.                 "You have not saved the exam data yet. Do you want to save the exam data before BOOM? All unsaved fields will be erased.",
  29.                 QtGui.QMessageBox.Save, QtGui.QMessageBox.Discard, QtGui.QMessageBox.Cancel)
  30.         print "changeValue ended"
  31.  
  32. def main():
  33.     app = QtGui.QApplication(sys.argv)
  34.     ex = Example()
  35.     sys.exit(app.exec_())
  36.  
  37. if __name__ == '__main__':
  38.     main()
Advertisement
Add Comment
Please, Sign In to add comment