Consider the following which is the program I thought you meant to write. It shows the image where you click and then makes it disappear 0.2 seconds latter. It would be more interesting with a longer delay.
The EventBox is needed as neither Window or the Fixed emits button-press-event although they are Widgets. This might have changed in a latter version than I have so it might be possible to omit it. But the code didn't work without it on my machine.
Calling show on the EventBox and Fixed was redundant as the window.show_all()
will show them as they are part of the tree at that time. But the show call on the Image is not unless you are using the version of GTK where widgets are shown by default instead of hidden. As the Image does not exist at that time.
from gi.repository import Gtk, GLib
window = Gtk.Window()
window.set_title('Dalle Test')
window.set_size_request(320, 240)
eventbox = Gtk.EventBox()
window.add(eventbox)
fixed = Gtk.Fixed()
eventbox.add(fixed)
def callback(window, event, *data):
print('Clicked at x=', event.x, "and y=", event.y)
image = Gtk.Image()
image.show()
image.set_from_file("FF0000.png")
image.set_size_request(64,64)
fixed.put(image, int(event.x), int(event.y))
def remove():
fixed.remove(image)
GLib.timeout_add(200, remove)
eventbox.connect('button-press-event', callback)
window.connect('destroy', lambda w: Gtk.main_quit())
window.show_all()
Gtk.main()