문제

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