Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python Gtk3中使弹出的GtkMenu透明且无边框_Python_User Interface_Cairo_Gtk3 - Fatal编程技术网

在python Gtk3中使弹出的GtkMenu透明且无边框

在python Gtk3中使弹出的GtkMenu透明且无边框,python,user-interface,cairo,gtk3,Python,User Interface,Cairo,Gtk3,我在使用Python和Gtk3创建一个无边界和透明的弹出菜单时遇到了问题。使用相同的代码,我可以使我的主窗口和消息对话框的样式适当,那么我的代码怎么了?在CSS定义中添加边框样式:none(或下面的每一面)只会删除底部边框。这是我的屏幕截图。您可以看到后面的主窗口格式正确。Cairo正确地绘制了弹出窗口的背景(注意白色矩形内的圆角,但它不是透明的) EDIT通过获取Gtk.menu的父菜单并在其上设置/绘制,我能够使菜单透明。但我还没能去掉顶部、左侧和右侧的边界。就在底部 以下是相关代码: d

我在使用Python和Gtk3创建一个无边界和透明的弹出菜单时遇到了问题。使用相同的代码,我可以使我的主窗口和消息对话框的样式适当,那么我的代码怎么了?在CSS定义中添加
边框样式:none
(或下面的每一面)只会删除底部边框。这是我的屏幕截图。您可以看到后面的主窗口格式正确。Cairo正确地绘制了弹出窗口的背景(注意白色矩形内的圆角,但它不是透明的)

EDIT通过获取
Gtk.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)
尝试:


无益。我试过了。我能做的唯一工作就是使半径尽可能接近开罗绘制的半径。但是,您仍然可以看到顶部、左侧和右侧边框比底部边框稍厚(这是0px宽度影响的唯一边框)
border-radius: 15       
border-width: 0