Consider this Python program which uses PyGtk and Hippo Canvas to display a clickable text label. Clicking the text label replaces it with a Hippo CanvasEntry widget which contains the text of the label.
import pygtk
pygtk.require('2.0')
import gtk, hippo
def textClicked(text, event, row):
input = hippo.CanvasEntry()
input.set_property('text', text.get_property('text'))
parent = text.get_parent()
parent.insert_after(input, text)
parent.remove(text)
def main():
canvas = hippo.Canvas()
root = hippo.CanvasBox()
canvas.set_root(root)
text = hippo.CanvasText(text=u'Some text')
text.connect('button-press-event', textClicked, text)
root.append(text)
window = gtk.Window()
window.connect('destroy', lambda ignored: gtk.main_quit())
window.add(canvas)
canvas.show()
window.show()
gtk.main()
if __name__ == '__main__':
main()
How can the CanvasEntry created when the text label is clicked be automatically focused at creation time?