How to use Gtk3 GtkTreeRowReference in Python

I am trying to call a Gtk3 function GtkTreeRowReference()without any success. I am trying to delete several records from ListStoreusing the appropriate TreeView set to MULTIPLE mode. I want to save TreeRowReferencefor each item ListStorespecified in the selection, and use it to delete the items ListStore, because these paths must be updated as the ListStore items reached earlier in the selection are deleted. I found many usage references TreeRowReferencesin PyGtk 2, and the PyGObject tutorial refers to their use, but does not provide a real example. I tried many ways to call GtkTreeRowReference()without success. For instance:

hit_rows = []
for row in range(len(self.selection.get_selected_rows()):
    hit = self.selection.get_selected_rows()[row]
    hit_row = Gtk.TreeRowReference(liststore, hit)
    hit_rows.append(hit_row)

creates this fatal error message: "TypeError: function takes at most 0 arguments (2 given)"when my program hits a line Gtk.TreeRowReference. The selection strings already contain a link to ListStore, so they tried again only using the selection string as an argument, but she complained that the function still insists on 0 arguments, and I tried to pass it 1 argument.

I also tried things like this:

hit_rows = []
for row in range(len(self.selection.get_selected_rows())):
    hit = self.selection.get_selected_rows()[row]
    hit_row = hit.GtkTreeRowReference()
    hit_rows.append(hit_row)

These efforts provoked Python complaints "AttributeError: 'ListStore' object has no attribute 'GtkTreeRowReference'."by changing the call to TreeRowReference, Gtk_TreeRowReferenceand a few other options given the same error message.

- , Gtk.TreeRowReference PyGObject/Gtk3? Python, Gtk, , , - , .

+3
1

, Gtk.TreeRowReference (PyGObject + GTK + 3), Gtk.TreeRowReference.new. , :

selection = treeview.get_selection()
model, paths = selection.get_selected_rows()
refs = []
for path in paths:
    refs.append(Gtk.TreeRowReference.new(model, path))

, treeview . :

for ref in refs:
    path = ref.get_path()
    iter = model.get_iter(path)
    value = model.get(iter, 0)[0]
    print '(%s, %s)' % (path, value)

, .

+2

All Articles