나는 Python 2.7과 PyGTK로 프로젝트를 가지고있다.PyGTK에서 RGBA 컬러 맵 만들기
투명한 배경 창을 만들 필요가 있지만 이미지 (pixmap 및 마스크 기반)와 다른 개체를 창 내부에 표시 할 수 있어야합니다.
다음 코드를 사용하고 있지만 이미지 객체가 우분투 (Oneric Ocelot)에 표시되지 않고 아래에 게시 됨 (윈도우가 그렇지 않으면 버튼 객체로 표시되지만) 오류가 발생합니다. 이것은 Windows 7에서도 렌더링되지 않습니다 (이 오류는 아래에 게시 됨).
def expose(widget, event):
cr = widget.window.cairo_create()
# Sets the operator to clear which deletes everything below where an object is drawn
cr.set_operator(cairo.OPERATOR_CLEAR)
# Makes the mask fill the entire window
cr.rectangle(0.0, 0.0, *widget.get_size())
# Deletes everything in the window (since the compositing operator is clear and mask fills the entire window
cr.fill()
# Set the compositing operator back to the default
cr.set_operator(cairo.OPERATOR_OVER)
hab_fish_win = gtk.Window()
hab_fish_win.resize(640, 480)
hab_fish_win.set_resizable(False)
hab_fish_win.set_decorated(False)
hab_fish_win.set_has_frame(False)
hab_fish_win.set_position(gtk.WIN_POS_CENTER)
hab_fish_win.set_app_paintable(True)
screen = hab_fish_win.get_screen()
rgba = screen.get_rgba_colormap()
hab_fish_win.set_colormap(rgba)
hab_fish_win.connect('expose-event', expose)
hab_fish_win.show()
WINDOWS 7 RUN :
Traceback (most recent call last): File "C:\Users\user\MousePaw Games\Word4Word\PYM\fishtest2.py", line 337, in HAB_FISH() File "C:\Users\user\MousePaw Games\Word4Word\PYM\fishtest2.py", line 100, in init hab_fish_win.set_colormap(rgba) TypeError: Gtk.Widget.set_colormap() argument 1 must be gtk.gdk.Colormap, not None
빠른 "인쇄 RGBA는"RGBA는 "없음"따라서 오류가 없음을 확인합니다.
우분투 "ONERIC 오셀롯"RUN :
Gtk Warning: Attempt to draw a drawable with depth 24 to a drawable with depth 32
을 무슨 일이야? 나는 그 창에 투명한 배경이 필사적으로 필요하다.