gtk.menu_button
Module for [MenuButton] class
Types 3
The #GtkMenuButton widget is used to display a popup when clicked on. This popup can be provided either as a #GtkMenu, a #GtkPopover or an abstract #GMenuModel.
The #GtkMenuButton widget can hold any valid child widget. That is, it can hold almost any other standard #GtkWidget. The most commonly used child is #GtkImage. If no widget is explicitely added to the #GtkMenuButton, a #GtkImage is automatically created, using an arrow image oriented according to #GtkMenuButton:direction or the generic “open-menu-symbolic” icon if the direction is not set.
The positioning of the popup is determined by the #GtkMenuButton:direction property of the menu button.
For menus, the #GtkWidget:halign and #GtkWidget:valign properties of the menu are also taken into account. For example, when the direction is [gtk.types.ArrowType.Down] and the horizontal alignment is [gtk.types.Align.Start], the menu will be positioned below the button, with the starting edge (depending on the text direction) of the menu aligned with the starting edge of the button. If there is not enough space below the button, the menu is popped up above the button instead. If the alignment would move part of the menu offscreen, it is “pushed in”.
Direction = Down
- halign = start

- halign = center

- halign = end

Direction = Up
- halign = start

- halign = center

- halign = end

Direction = Left
- valign = start

- valign = center

- valign = end

Direction = Right
- valign = start

- valign = center

- valign = end

CSS nodes
GtkMenuButton has a single CSS node with name button. To differentiate it from a plain #GtkButton, it gets the .popup style class.
MenuButton self()Returns `this`, for use in `with` statements.MenuButtonGidBuilder builder()Get builder for [gtk.menu_button.MenuButton] Returns: New builder objectgtk.container.Container alignWidget() @propertyGet `alignWidget` property. Returns: The #GtkWidget to use to align the menu with.void alignWidget(gtk.container.Container propval) @propertySet `alignWidget` property. Params: propval = The #GtkWidget to use to align the menu with.gtk.types.ArrowType direction() @propertyGet `direction` property. Returns: The #GtkArrowType representing the direction in which the menu or popover will be popped out.void direction(gtk.types.ArrowType propval) @propertySet `direction` property. Params: propval = The #GtkArrowType representing the direction in which the menu or popover will be popped out.gio.menu_model.MenuModel menuModel() @propertyGet `menuModel` property. Returns: The #GMenuModel from which the popup will be created. Depending on the #GtkMenuButton:use-popover property, that may be a menu or a popover.void menuModel(gio.menu_model.MenuModel propval) @propertySet `menuModel` property. Params: propval = The #GMenuModel from which the popup will be created. Depending on the #GtkMenuButton:use-popover property, that may be a menu or a popover.gtk.popover.Popover popover() @propertyGet `popover` property. Returns: The #GtkPopover that will be popped up when the button is clicked.void popover(gtk.popover.Popover propval) @propertySet `popover` property. Params: propval = The #GtkPopover that will be popped up when the button is clicked.gtk.menu.Menu popup() @propertyGet `popup` property. Returns: The #GtkMenu that will be popped up when the button is clicked.void popup(gtk.menu.Menu propval) @propertySet `popup` property. Params: propval = The #GtkMenu that will be popped up when the button is clicked.bool usePopover() @propertyGet `usePopover` property. Returns: Whether to construct a #GtkPopover from the menu model, or a #GtkMenu.void usePopover(bool propval) @propertySet `usePopover` property. Params: propval = Whether to construct a #GtkPopover from the menu model, or a #GtkMenu.gtk.widget.Widget getAlignWidget()Returns the parent #GtkWidget to use to line up with menu. Returns: a #GtkWidget value or nullgtk.types.ArrowType getDirection()Returns the direction the popup will be pointing at when popped up. Returns: a #GtkArrowType valuegio.menu_model.MenuModel getMenuModel()Returns the #GMenuModel used to generate the popup. Returns: a #GMenuModel or nullgtk.popover.Popover getPopover()Returns the #GtkPopover that pops out of the button. If the button is not using a #GtkPopover, this function returns null. Returns: a #GtkPopover or nullgtk.menu.Menu getPopup()Returns the #GtkMenu that pops out of the button. If the button does not use a #GtkMenu, this function returns null. Returns: a #GtkMenu or nullbool getUsePopover()Returns whether a #GtkPopover or a #GtkMenu will be constructed from the menu model. Returns: true if using a #GtkPopovervoid setAlignWidget(gtk.widget.Widget alignWidget = null)Sets the #GtkWidget to use to line the menu with when popped up. Note that the align_widget must contain the #GtkMenuButton itself.void setDirection(gtk.types.ArrowType direction)Sets the direction in which the popup will be popped up, as well as changing the arrow’s direction. The child will not be changed to an arrow if it was customized.void setMenuModel(gio.menu_model.MenuModel menuModel = null)Sets the #GMenuModel from which the popup will be constructed, or null to dissociate any existing menu model and disable the button.void setPopover(gtk.widget.Widget popover = null)Sets the #GtkPopover that will be popped up when the menu_button is clicked, or null to dissociate any existing popover and disable the button.void setPopup(gtk.widget.Widget menu = null)Sets the #GtkMenu that will be popped up when the menu_button is clicked, or null to dissociate any existing menu and disable the button.void setUsePopover(bool usePopover)Sets whether to construct a #GtkPopover instead of #GtkMenu when [gtk.menu_button.MenuButton.setMenuModel] is called. Note that this property is only consulted when a new menu model is set.T alignWidget(gtk.container.Container propval)Set `alignWidget` property. Params: propval = The #GtkWidget to use to align the menu with. Returns: Builder instance for fluent chainingT direction(gtk.types.ArrowType propval)Set `direction` property. Params: propval = The #GtkArrowType representing the direction in which the menu or popover will be popped out. Returns: Builder instance for fluent chainingT menuModel(gio.menu_model.MenuModel propval)Set `menuModel` property. Params: propval = The #GMenuModel from which the popup will be created. Depending on the #GtkMenuButton:use-popover property, that may be a menu or a popover.T popover(gtk.popover.Popover propval)Set `popover` property. Params: propval = The #GtkPopover that will be popped up when the button is clicked. Returns: Builder instance for fluent chainingT popup(gtk.menu.Menu propval)Set `popup` property. Params: propval = The #GtkMenu that will be popped up when the button is clicked. Returns: Builder instance for fluent chainingT usePopover(bool propval)Set `usePopover` property. Params: propval = Whether to construct a #GtkPopover from the menu model, or a #GtkMenu. Returns: Builder instance for fluent chainingFluent builder for [gtk.menu_button.MenuButton]