Python と Gtk3 を使用して、ポップアップ メニューを縁なしで透明にするのに問題があります。同じコードを使用して、メイン ウィンドウとメッセージ ダイアログのスタイルを適切に設定できます。border-style: none
CSS 定義に (または以下のように各辺に)追加すると、下の境界線のみが削除されます。これが私が持っているもののスクリーンショットです。後ろに正しくフォーマットされたメイン ウィンドウが表示されます。Cairo はポップアップの背景を正しく描画しています(白い四角形の内側の角が丸くなっていることに注意してください。ただし、透明ではありません)。
EDITGtk.Menu
の親を取得し、その上に設定/描画することで、メニューを透明にすることができました。しかし、上、左、右の境界線を取り除くことができませんでした。ちょうど底。
関連するコードは次のとおりです。
def __init__(self):
....#other code...
css.load_from_data("""
.title { background-color: rgba(255, 255, 255, 0); color: rgba(%s,1);}
.iconview { background-color: rgba(255, 255, 255, 0); color: rgba(%s,1); font-size:%i}
.background2 { background-color: rgba(%s,0.7); color: rgba(%s, 1);border-top-style:none; border-left-style:none; border-right-style:none; border-bottom-style:none;}
""" % (str(sel f.FONT_rgb).strip('[]'),str(self.FONT_rgb).strip('[]'),FONTSIZE,str(self.BG_rgb).strip('[]'),str(self.FONT_rgb).strip('[]')))
Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), css,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
parent=self.popup.get_parent()
screen=parent.get_screen()
parent.set_visual(screen.get_rgba_visual())
parent.set_app_paintable(True)
parent.get_style_context().add_class('background2')
for child in self.popup.get_children():
child.get_style_context().add_class('iconview')
child.set_app_paintable(True)
self.popup.get_style_context().add_class('iconview')
self.popup.set_app_paintable(True)
parent.connect("draw", self.draw_window_cb)
def on_mouse_click(self,widget, event):
# Check if right mouse button was preseed
if event.type == Gdk.EventType.BUTTON_RELEASE and self.dragging==False:
if event.button == 3 and path != None:
self.popup.popup(None, None, None, None, event.button, event.time)