Aswin Murugesh
Aswin Murugesh

Reputation: 11070

Map a key press to a button click in Gtk Python

I want a key press to be mapped with a button click function in Gtk-python, i.e. if Enter key is pressed, the data-process function should execute, which is called by pressing the process button.

Can this be done?

Upvotes: 0

Views: 1220

Answers (2)

somepati
somepati

Reputation: 1

Assuming you are using a gtk.Entry() and a gtk.Button(), I think what you need to do is just connecting the gtk.Entry() to your data-process function like this: b = gtk.Button("Process") b.connect("clicked", data-process) e = gtk.Entry() e.connect("activate", data-process)

That should do the "Trick".

Hope this helped.

Upvotes: 0

f4lco
f4lco

Reputation: 3814

Speculating this might a Gtk.Dialog, you can set the default response.

gtk_dialog_set_default_response ():

Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog. Pressing "Enter" normally activates the default widget.

Upvotes: 1

Related Questions