0
アクションを使用してツリービューウィジェットに右クリックしてコンテキストメニューを追加したいと思います。 Iはhttp://python-gtk-3-tutorial.readthedocs.io/en/latest/application.html#actionsとhttps://developer.gnome.org/gnome-devel-demos/stable/gmenu.py.htmlからミキシング情報により、このコードを試みたが、働いていない。PyGtk3アクションでツリービューの右クリックメニュー
action = Gio.SimpleAction.new("test", None)
action.connect('activate', self.my_func)
self.add_action(action)
self.tree_view.connect("button-press-event", self.on_click)
def on_click(self, widget, event):
if event.button == 3:
path, _, _, _ = widget.get_path_at_pos(int(event.x), int(event.y))
treeiter = self.model.get_iter(path)
action_group = Gio.ActionGroup()
action_group.action_added("app.test")
treeiter.insert_action_group(action_group)
menu = Gtk.Menu()
menu.attach_to_widget(treeiter)
menu.popup()
これは置き換えられた 'Gtk.ActionGroup'ではなく' Gio.ActionGroup'です。 – ptomato