In pygtk3, when using set_data, it complained RuntimeError: Data access methods are unsupported. Use normal Python attributes instead. In pygtk, I can use set_data to attach a widget to another widget and use get_data to retrieve the attached widget and do something. In pygtk3, how can I achieve it?
I couldn't provide a small code. A scenario is, for example, there is an entry and button. When clicking the button, set 'balabala' to the entry.
entry = Gtk.Entry.new()
button = Gtk.Button.new_with_label("Foo")
button.set_data('qqaa', entry) # In pygtk. How to do it in pygtk3?
button.connect("clicked", on_clicked)
def on_clicked(button):
entry = button.get_data('qqaa') # In pygtk. How to do it in pygtk3?
entry.set_text('balabala')
Edit: The solution is to use connect.The key point is that we can pass more than one parameter.
def master_building_entry_changed(menu, master_building_id, AirBuildr_html_entry):
idx = menu.get_active()
if idx != master_building_id:
master_building_id = idx
print(master_building_id)
...
master_building_entry = make_menu(MASTER_BUILDING, master_building_id)
# I passed 2 parameters: master_building_id - an int and AirBuildr_html_entry - a Gtk,Entry
master_building_entry.connect("changed", master_building_entry_changed, master_building_id, AirBuildr_html_entry)
...