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?
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.
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.
Add commentbutton. so, both actions call the same function.I want to do a similar thing in my appkey-press-eventorkey-release-eventand check the event passed to the callback forEnterkey and call your button click function? As mentioned by user4815162342 key events are sent to the current focus widget.