smheidrich
smheidrich

Reputation: 4548

Setting sensitivity of menu item associated with Gio.Action

I created a menubar using the Python bindings for GTK3 and Gio.Action instead of Gtk.Action, similar to how it is described in this answer.

But now I'm having trouble trying to dynamically set the sensitivity of a menu item (whether it is greyed out). Gtk.Action provides a simple set_sensitive method, but I can't find a clean way of getting the Gtk.Action associated with my Gio.Action. Gtk.Application only has methods for directly getting the Gio.MenuModels, not the Gtk.Menu, for instance.

Upvotes: 1

Views: 470

Answers (1)

TingPing
TingPing

Reputation: 2302

Gio.SimpleAction.set_enabled()

action = Gio.SimpleAction.new('my-action', None)
action.set_enabled(False) # This makes it insensitive

Upvotes: 1

Related Questions