Search code examples
pythongtkgtk3pygobject

Gtk Popover Menu is not using the default padding


I created a GtkPopoverMenu and added some text buttons to it, but I can't get it to follow the same padding as other popovers, like the one in Nautilus.

The default style classes are being applied, and GtkInspector shows the same padding values as the popover in Nautilus, but, visually, the padding isn't there.

Here is the relevant part of the code:

pbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)
popover.add(pbox)

one = Gtk.ModelButton.new()
one.set_label("Button One")
pbox.pack_start(one, False, False, 0)

two = Gtk.ModelButton.new()
two.set_label("Button Two")
pbox.pack_start(two, False, False, 0)

three = Gtk.ModelButton.new()
three.set_label("Button Three")
pbox.pack_start(three, False, False, 0)

And how it looks vs how the one in Nautilus looks: Image

And the full code: Code

Am I missing something here?


Solution

  • Nautilus uses a combination of margin and padding for its Popover.

    I hope the screenshot demonstrates it. The first is the Popover as it is with your code. The second one has a margin but as you can see, the selection directly touches the text. Therefore the third Popover has margin and padding.

    screenshot of three different popovers

    The margin can be set with widget.set_property('margin', 10) and the padding with a css file.