简体   繁体   中英

PyGtk: Scrollist with Entry, can I set an Id

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM