I trying to do my first desktop app in Python and GTK3, but I quickly run into a problem. I want to display a TreeView with columns URL, Title, and delete icon, but I'm having problem in displaying and icon that can be clicked, and that deletes the row.
I found that question, but the solution didn't work for me.
Is there any way to do what I want? Or did I design it wrong?
Code:
# List
self.store = Gtk.ListStore(str, str, str)
self.store.append(['https://www.youtube.com/watch?v=dQw4w9WgXcQ', # URL
'Rick Astley - Never Gonna Give You Up', # Title
'edit-delete']) # Action icon
tree = Gtk.TreeView(self.store)
tree.set_size_request(600, 400)
# Editable URL
url = Gtk.CellRendererText()
url.set_property("editable", True)
url.connect("edited", self.text_edited)
column_url = Gtk.TreeViewColumn("YouTube URL", url, text=0)
column_url.set_min_width(300)
tree.append_column(column_url)
# Title
title = Gtk.CellRendererText()
column_title = Gtk.TreeViewColumn("Title", title, text=1)
tree.append_column(column_title)
# Action icon
action_icon = Gtk.CellRendererPixbuf()
# action_icon.connect("clicked", self.action_icon_clicked)
column_action_icon = Gtk.TreeViewColumn("", action_icon, icon_name=2)
tree.append_column(column_action_icon)
Thanks for help