I have a scroll list on my window that I am going to insert 2 entry for each row, I am trying to understand how I can catch the entry that has been changed and update my array with this value.

I will explain what is my code:

I have an array that has 2 fields: Name and Description Each row has 2 entry, Name and Description When I am going to modify the row number 2 I want to update my object on my array:

rows[1].name = XXX rows[1].description = YYY
有帮助吗?

解决方案

You might also want to consider using Gtk.TreeView with editable cells. The underlying Gtk.ListStore could replace your array.

But you can also use your existing entries and pass any data you want as "user data" to the callback for the "changed" signal.

def on_entry_changed(entry, data):
    print("Row %d, Column %s - %s", data[0], data[1], entry.get_text())

for i in xrange(10):
    name = Gtk.Entry()
    name.connect("changed", on_entry_changed, (i, "name"))
    description = Gtk.Entry()
    description.connect("changed", on_entry_changed, (i, "description"))
    # add your entries to a box or whatever
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top