Sunday, 22 May 2022

Popover Menu

The script shows how to create a popover menu in a GTK3 app, users can activate the menu by clicking the menu button placed on the top left corner of this app.



  1. Define a popover with Gtk.Popover. Basically, a popover can hold any gtk widget. In this example, a menu with some options are hold by the popover.
  2. Define a set of menu items by Gtk.ModelButton, each button when clicked will trigger an event handler. Place all buttons in a box, and place the box in the popover.
  3. Define a menu button by Gtk.MenuButton, attach the popover to the menu button during the creation of the button.
  4. Define an entry for editing selected list item. The key-press-event of the entry can trigger a handler, named self.entryKey in this app, which processes the change of text.
  5. In self.entryKey, the function Gtk.keyval_name(event.keyval) returns the name of the key which has just been pressed. The name for the return key is Return

Source Code



No comments:

Post a Comment