/GUI/Win32/Cursors.py

https://bitbucket.org/alsh/pygui-mirror · Python · 33 lines · 21 code · 6 blank · 6 comment · 0 complexity · b2ff87852cb6a8bcb7d5209271588a71 MD5 · raw file

  1. #--------------------------------------------------------------------------
  2. #
  3. # Python GUI - Cursors - Win32
  4. #
  5. #--------------------------------------------------------------------------
  6. import win32gui as gui
  7. from GCursors import Cursor as GCursor
  8. class Cursor(GCursor):
  9. def _from_win_cursor(cls, hcursor):
  10. cursor = cls.__new__(cls)
  11. cursor._win_cursor = hcursor
  12. return cursor
  13. _from_win_cursor = classmethod(_from_win_cursor)
  14. def __str__(self):
  15. return "<Cursor hcursor=0x%x>" % self._win_cursor
  16. def _init_from_image_and_hotspot(self, image, hotspot):
  17. #print "Cursor._init_from_image_and_hotspot:" ###
  18. hicon = image._win_image.GetHICON()
  19. iconinfo = gui.GetIconInfo(hicon)
  20. gui.DestroyIcon(hicon)
  21. flag, xhot, yhot, hbmMask, hbmColor = iconinfo
  22. xhot, yhot = hotspot
  23. cursorinfo = (True, xhot, yhot, hbmMask, hbmColor)
  24. win_cursor = gui.CreateIconIndirect(cursorinfo)
  25. gui.DeleteObject(hbmMask)
  26. gui.DeleteObject(hbmColor)
  27. self._win_cursor = win_cursor