python-3.xgtkgtk3pygobject

How I create a "HeaderMenu" with a Popover menu in GTK?


I'm trying to create a "HeaderMenu" like this:

enter image description here

But only I got it:

enter image description here

I'm using GtkMenuButton within a GtkHeaderBar. How do I get a menu like the first picture?

Codes:

Glade file Python code


Solution

  • Starting with GTK+ 3.12, set the use-popover property of the GtkMenuButton to TRUE.

    EDIT Oh, you are actually using a GtkMenu and the popup property of GtkMenuButton. For this to work, you need to switch to using the menu-model property that uses GMenu instead of a GtkMenu. And no, a GtkMenu is not a GMenu, so you cannot simply change the name of the property in the glade file. GMenus are architecturally different from GtkMenus, so you will have some rewriting to do.