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.
- 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. - 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. - Define a menu button by
Gtk.MenuButton
, attach the popover to the menu button during the creation of the button. - Define an entry for editing selected list item. The
key-press-event
of the entry can trigger a handler, namedself.entryKey
in this app, which processes the change of text. - In
self.entryKey
, the functionGtk.keyval_name(event.keyval)
returns the name of the key which has just been pressed. The name for the return key is Return.
No comments:
Post a Comment