This is a MenuButton that already has a popover attached and a property for setting the popover child directly. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
21 lines
641 B
Python
21 lines
641 B
Python
# Copyright 2022 (c) Anna Schumaker.
|
|
"""Helper classes for Buttons."""
|
|
from gi.repository import GObject
|
|
from gi.repository import Gtk
|
|
|
|
|
|
class PopoverButton(Gtk.MenuButton):
|
|
"""A MenuButton with a Gtk.Popover attached."""
|
|
|
|
popover_child = GObject.Property(type=Gtk.Widget)
|
|
|
|
def __init__(self, **kwargs):
|
|
"""Initialize a popover.Button."""
|
|
super().__init__(popover=Gtk.Popover(), **kwargs)
|
|
self.bind_property("popover-child", self.get_popover(), "child")
|
|
self.get_popover().set_child(self.popover_child)
|
|
|
|
def popdown(self):
|
|
"""Close the popover."""
|
|
self.get_popover().popdown()
|