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.

cursor.py 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/usr/bin/env python
  2. """$Id: cursor.py,v 1.1 2003/07/01 14:18:37 phil Exp $
  3. **
  4. ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
  5. **
  6. ** This file is part of an example program for TQt. This example
  7. ** program may be used, distributed and modified without limitation.
  8. **
  9. ***************************************************************************"""
  10. import sys
  11. from python_tqt.qt import *
  12. # cb_bits and cm_bits were generated by X bitmap program.
  13. cb_width = 32
  14. cb_height = 32
  15. # cursor bitmap
  16. cb_bits = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x0f\x00" \
  17. "\x00\x06\x30\x00\x80\x01\xc0\x00\x40\x00\x00\x01" \
  18. "\x20\x00\x00\x02\x10\x00\x00\x04\x08\x3e\x3e\x08" \
  19. "\x08\x03\xe0\x08\xc4\x00\x00\x11\x04\x1e\x78\x10" \
  20. "\x02\x0c\x30\x20\x02\x40\x00\x20\x02\x40\x00\x20" \
  21. "\x02\x40\x00\x20\x02\x20\x04\x20\x02\x20\x04\x20" \
  22. "\x02\x10\x08\x20\x02\x08\x08\x20\x02\xf0\x07\x20" \
  23. "\x04\x00\x00\x10\x04\x00\x00\x10\x08\x00\xc0\x08" \
  24. "\x08\x3c\x30\x08\x10\xe6\x19\x04\x20\x00\x0f\x02" \
  25. "\x40\x00\x00\x01\x80\x01\xc0\x00\x00\x06\x30\x00" \
  26. "\x00\xf8\x0f\x00\x00\x00\x00\x00"
  27. cm_width = 32
  28. cm_height = 32
  29. # cursor bitmap mask
  30. cm_bits = "\x00\x00\x00\x00\x00\xf8\x1f\x00\x00\xfe\x3f\x00" \
  31. "\x80\x07\xf0\x00\xc0\x01\xc0\x01\x60\x00\x00\x03" \
  32. "\x30\x00\x00\x06\x18\x00\x00\x0c\x0c\x3e\x3e\x18" \
  33. "\x0e\x03\xe0\x18\xc6\x00\x00\x31\x07\x1e\x78\x30" \
  34. "\x03\x0c\x30\x60\x03\x40\x00\x60\x03\x40\x00\x60" \
  35. "\x03\x40\x00\x60\x03\x20\x04\x60\x03\x20\x04\x60" \
  36. "\x03\x10\x08\x60\x03\x08\x08\x60\x03\xf0\x07\x60" \
  37. "\x06\x00\x00\x30\x06\x00\x00\x30\x0c\x00\xc0\x18" \
  38. "\x0c\x3c\x30\x18\x18\xe6\x19\x0c\x30\x00\x0f\x06" \
  39. "\x60\x00\x00\x03\xc0\x01\xc0\x01\x80\x07\xf0\x00" \
  40. "\x00\xfe\x3f\x00\x00\xf8\x0f\x00"
  41. # The CursorView contains many labels with different cursors.
  42. class CursorView( TQWidget ): # cursor view
  43. def __init__( self ):
  44. TQWidget.__init__( self )
  45. # Constructs a cursor view.
  46. #enum CursorShape { ArrowCursor, UpArrowCursor, CrossCursor, WaitCursor, IbeamCursor, SizeVerCursor, SizeHorCursor, SizeBDiagCursor, SizeFDiagCursor, SizeAllCursor, BlankCursor, SplitVCursor, SplitHCursor, PointingHandCursor, ForbiddenCursor, WhatsThisCursor, LastCursor = WhatsThisCursor, BitmapCursor = 24 }
  47. shape = [
  48. "ArrowCursor", "UpArrowCursor", "CrossCursor",
  49. "WaitCursor", "IbeamCursor", "SizeVerCursor",
  50. "SizeHorCursor", "SizeBDiagCursor", "SizeFDiagCursor",
  51. "SizeAllCursor", "BlankCursor", "SplitVCursor",
  52. "SplitHCursor", "PointingHandCursor", "ForbiddenCursor",
  53. "WhatsThisCursor"
  54. ]
  55. name = [
  56. "standard arrow cursor", "upwards arrow",
  57. "crosshair", "hourglass/watch",
  58. "ibeam/text entry", "vertical resize",
  59. "horizontal resize", "diagonal resize (/)",
  60. "diagonal resize (\)", "all directions resize",
  61. "blank/invisible cursor", "vertical splitting",
  62. "horziontal splitting", "a pointing hand",
  63. "a slashed circle", "an arrow with a question mark"
  64. ]
  65. self.setCaption( "CursorView" ) # set window caption
  66. grid = TQGridLayout( self, 5, 4, 20 )
  67. i=0
  68. for y in range( 0, 4, 1 ) : # create the small labels
  69. for x in range( 0, 4, 1 ) :
  70. label = TQLabel( self )
  71. label.setCursor( TQCursor(i) )
  72. label.setText( shape[i] );
  73. label.setAlignment( self.AlignCenter )
  74. label.setFrameStyle( TQFrame.Box | TQFrame.Raised )
  75. grid.addWidget( label, x, y )
  76. TQToolTip.add( label, name[i] )
  77. i += 1
  78. cb = TQBitmap( cb_width, cb_height, cb_bits, True )
  79. cm = TQBitmap( cm_width, cm_height, cm_bits, True )
  80. custom = TQCursor( cb, cm ) # create bitmap cursor
  81. label = TQLabel( self ) # create the big label
  82. label.setCursor( custom )
  83. label.setText( "Custom bitmap cursor" )
  84. TQToolTip.add( label, "custom bitmap cursor" )
  85. label.setAlignment( self.AlignCenter )
  86. label.setFrameStyle( TQFrame.Box | TQFrame.Sunken )
  87. grid.addMultiCellWidget( label, 4, 4, 0, 3 )
  88. # Create and display a CursorView.
  89. def main( args ):
  90. a = TQApplication(sys.argv) # application object
  91. v = CursorView() # cursor view
  92. v.setCaption( "TQt Example - Cursors" )
  93. a.setMainWidget( v )
  94. v.show()
  95. a.exec_loop()
  96. if __name__=="__main__":
  97. main(sys.argv)