PageRenderTime 87ms CodeModel.GetById 76ms app.highlight 8ms RepoModel.GetById 0ms app.codeStats 0ms

/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
 7import win32gui as gui
 8from GCursors import Cursor as GCursor
 9
10class Cursor(GCursor):
11
12    def _from_win_cursor(cls, hcursor):
13        cursor = cls.__new__(cls)
14        cursor._win_cursor = hcursor
15        return cursor
16
17    _from_win_cursor = classmethod(_from_win_cursor)
18
19    def __str__(self):
20        return "<Cursor hcursor=0x%x>" % self._win_cursor
21
22    def _init_from_image_and_hotspot(self, image, hotspot):
23        #print "Cursor._init_from_image_and_hotspot:" ###
24        hicon = image._win_image.GetHICON()
25        iconinfo = gui.GetIconInfo(hicon)
26        gui.DestroyIcon(hicon)
27        flag, xhot, yhot, hbmMask, hbmColor = iconinfo
28        xhot, yhot = hotspot
29        cursorinfo = (True, xhot, yhot, hbmMask, hbmColor)
30        win_cursor = gui.CreateIconIndirect(cursorinfo)
31        gui.DeleteObject(hbmMask)
32        gui.DeleteObject(hbmColor)
33        self._win_cursor = win_cursor