SIP4 python bindings for TQt
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

66 lignes
1.6KB

  1. # This is part of the dragdrop example.
  2. from python_tqt.qt import *
  3. def canDecode(e):
  4. return e.provides( "secret/magic" )
  5. def decode(e):
  6. payload = str(e.data( "secret/magic" ))
  7. if ( str(payload) != '' ):
  8. e.accept()
  9. return TQString("The secret number is "+str(ord(payload)) )
  10. return None
  11. class SecretDrag(TQStoredDrag):
  12. def __init__(self, secret, parent=None, name=None):
  13. TQStoredDrag.__init__(self, 'secret/magic', parent, name)
  14. data = TQByteArray(chr(secret))
  15. self.setEncodedData( data )
  16. # XPM
  17. picture_xpm = [
  18. "16 16 3 1",
  19. " c None",
  20. ". c #000000",
  21. "X c #FFFF00",
  22. " ..... ",
  23. " ..XXXXX.. ",
  24. " .XXXXXXXXX. ",
  25. " .XXXXXXXXXXX. ",
  26. " .XX..XXX..XX. ",
  27. ".XXXXXXXXXXXXX. ",
  28. ".XX...XXX...XX. ",
  29. ".XXX..XXX..XXX. ",
  30. ".XXXXXXXXXXXXX. ",
  31. ".XXXXXX.XXXXXX. ",
  32. " .XX.XX.XX.XX. ",
  33. " .XXX..X..XXX. ",
  34. " .XXXXXXXXX. ",
  35. " ..XXXXX.. ",
  36. " ..... ",
  37. " "
  38. ]
  39. class SecretSource(TQLabel):
  40. def __init__(self, secret, parent=None, name=None):
  41. TQLabel.__init__(self, "Secret", parent, name)
  42. self.setBackgroundColor( TQt.blue.light() )
  43. self.setFrameStyle( TQLabel.Box | TQLabel.Sunken )
  44. self.setMinimumHeight( self.sizeHint().height()*2 )
  45. self.setAlignment( TQLabel.AlignCenter )
  46. self.mySecret = secret
  47. def mousePressEvent(self, e):
  48. sd = SecretDrag( self.mySecret, self )
  49. sd.setPixmap(TQPixmap(picture_xpm),TQPoint(8,8))
  50. sd.dragCopy()
  51. self.mySecret = self.mySecret + 1