2011-10-20 2 views
4

나는 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

을 무슨 일이야? 나는 그 창에 투명한 배경이 필사적으로 필요하다.

답변

3

오랜 시간의 연구 끝에 알 수 있듯이 Windows는 이러한 종류의 투명성을 지원하지 않습니다. 리눅스 오류에 관해서는, 나는 모른다.

저는 PyGObject로 포팅 중이며, 내 목적으로 다른 방법을 사용하고 있습니다. 나는이 대답의 독자들에게 그것을 제안 할 것을 제안한다.

관련 문제