당신이 어떤 libX11 기능의 파이썬 Xlib를 동등한 찾아야 할 때 염두에 두어야 할 두 가지가 있습니다 libX11 달리
- 는 파이썬 Xlib를 객체 지향이다; 이 경우
XCreatePixmapCursor()
은 pixmap.create_cursor()
으로 변환됩니다.
- 대부분의 python-xlib 메소드는 X11 메시지에 직접 매핑됩니다. 대부분의 도우미 기능은 구현되지 않습니다. 일치하는 python-xlib 메서드를 찾을 수없는 경우 libX11 source code을보고 기능이 후드 아래의 다른 함수를 호출하는 도우미인지 확인하는 것이 좋습니다. 이 경우 source code of
XDefineCursor()
을 보면 실제로는 XChangeWindowAttributes()
이 호출되는 것을 볼 수 있습니다. 즉, win.change_attributes()
을 python-xlib에 사용하려고합니다. 커서 폰트에서 커서를 사용하는 XCreateFontCursor()
를 사용하려면
는 두 번째 가이드 라인을 다시 적용이 font.create_glyph_cursor()
에 해당하는 후드 아래 XCreateGlyphCursor()
부르고있다.
여기에, 함께 그 모두를 두는 것은 당신이 얻을 것이다 무엇 : 당신이 font.create_glyph_cursor()
로 호출에서 +1
의 중요성에 대해 궁금해하는 경우
# Create font cursor
font = display.open_font('cursor')
cursor = font.create_glyph_cursor(font, Xlib.Xcursorfont.crosshair, Xlib.Xcursorfont.crosshair+1, (65535, 65535, 65535), (0, 0, 0))
# Use PIL to load a cursor image and ensure that it's 1-bit as required
im = Image.open('cursor.png').convert('1')
w, h = im.size
# Create pixmap cursor
mask = win.create_pixmap(w, h, 1)
gc = mask.create_gc(foreground=0, background=1)
mask.put_pil_image(gc, 0, 0, im)
cursor = mask.create_cursor(mask, (0, 0, 0), (65535, 65535, 65535), 0, 0)
# Change cursors for given windows
win.change_attributes(cursor=cursor)
, 즉 source code of XCreateFontCursor()
설명입니다.