SIP4 python bindings for TQt
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tut7.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python
  2. # TQt tutorial 7.
  3. import sys
  4. from python_tqt.qt import *
  5. class LCDRange(TQVBox):
  6. def __init__(self,parent=None,name=None):
  7. TQVBox.__init__(self,parent,name)
  8. lcd = TQLCDNumber(2,self,'lcd')
  9. self.slider = TQSlider(TQt.Horizontal,self,'slider')
  10. self.slider.setRange(0,99)
  11. self.slider.setValue(0)
  12. self.connect(self.slider,SIGNAL('valueChanged(int)'),lcd,SLOT('display(int)'))
  13. self.connect(self.slider,SIGNAL('valueChanged(int)'),self,PYSIGNAL('valueChanged(int)'))
  14. def value(self):
  15. return self.slider.value()
  16. def setValue(self,value):
  17. self.slider.setValue(value)
  18. class MyWidget(TQVBox):
  19. def __init__(self,parent=None,name=None):
  20. TQVBox.__init__(self,parent,name)
  21. quit = TQPushButton("Quit",self,"quit")
  22. quit.setFont(TQFont("Times",18,TQFont.Bold))
  23. self.connect(quit,SIGNAL("clicked()"),tqApp,SLOT("quit()"))
  24. grid = TQGrid(4,self)
  25. self.lcdlist = []
  26. previous = None
  27. for r in range(4):
  28. for c in range(4):
  29. lr = LCDRange(grid)
  30. if previous is not None:
  31. self.connect(lr,PYSIGNAL("valueChanged(int)"),previous.setValue)
  32. previous = lr
  33. self.lcdlist.append(lr)
  34. a = TQApplication(sys.argv)
  35. w = MyWidget()
  36. a.setMainWidget(w)
  37. w.show()
  38. a.exec_loop()