2011-10-20 10 views
4

私はPython 2.7とPyGTKでプロジェクトを持っています。PyGTKでRGBAカラーマップを作成

透明な背景ウィンドウを作成する必要がありますが、イメージ(ピクスマップとマスクベース)やその他のオブジェクトをウィンドウ内に表示することはできます。

私は次のコードを使用していますが、画像オブジェクトはUbuntu(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は、 "なし"、これ誤りがないことを確認します。

UBUNTU "ONERIC OCELOT" RUN:

Gtk Warning: Attempt to draw a drawable with depth 24 to a drawable with depth 32

が起こっていますか?私は必然的に窓の透明な背景が必要です。

答えて

3

長年の調査の結果、私はWindowsがこのような透明性をサポートしていないことを発見しました。 Linuxのエラーに関しては、わかりません。

私はPyGObjectに移植しています。私の目的は別の方法です。私はこの答えの読者にそれを調べるよう勧めます。