user422100 user422100 - 10 months ago 54
Python Question

How to Set Call Back For Enter key of GtkTextView?

how can I set call back on enter key of GtkTextView Widget and set TextView to work like gtk.entry (single-line)?

import gtk

tv = gtk.TextView()

def keyPress(widget, event):
    if gtk.gdk.keyval_name(event.keyval) == 'Return':
        ## do something
        return True
    return False

tv.connect('key-press-event', keyPress)

win = gtk.Dialog()

But a question: If don't want multi-line input, so why you are using TextView instead of Entry?!