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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/usr/bin/env python
  2. # TQt tutorial 7.
  3. import sys
  4. from python_tqt import qt
  5. class LCDRange(qt.TQVBox):
  6. def __init__(self, parent=None, name=None):
  7. qt.TQVBox.__init__(self, parent, name)
  8. lcd = qt.TQLCDNumber(2, self, "lcd")
  9. self.slider = qt.TQSlider(qt.TQt.Horizontal, self, "slider")
  10. self.slider.setRange(0, 99)
  11. self.slider.setValue(0)
  12. self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), lcd, qt.SLOT("display(int)"))
  13. self.connect(self.slider, qt.SIGNAL("valueChanged(int)"), self, qt.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(qt.TQVBox):
  19. def __init__(self, parent=None, name=None):
  20. qt.TQVBox.__init__(self, parent, name)
  21. quit = qt.TQPushButton("Quit", self, "quit")
  22. quit.setFont(qt.TQFont("Times", 18, qt.TQFont.Bold))
  23. self.connect(quit, qt.SIGNAL("clicked()"), qt.tqApp, qt.SLOT("quit()"))
  24. grid = qt.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:
  31. self.connect(lr, qt.PYSIGNAL("valueChanged(int)"), previous.setValue)
  32. previous = lr
  33. self.lcdlist.append(lr)
  34. a = qt.TQApplication(sys.argv)
  35. w = MyWidget()
  36. a.setMainWidget(w)
  37. w.show()
  38. sys.exit(a.exec_loop())