Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxPython dialogs: "Enter" keyboard button would not "ok" the dialog

I am creating a custom wxPython dialog by subclassing wx.Dialog. When I press Enter while using it, (and while being focused on one of the form elements,) it just takes the focus to the next form element, while I want it to press the ok button.

How do I solve this?

like image 665
Ram Rachum Avatar asked Dec 13 '25 04:12

Ram Rachum


1 Answers

That should happen automatically if the button has the wx.ID_OK id. If that's impossible then the wx.StdDialogButtonSizer.SetAffirmativeButton() method could be a solution (using the StdDialogButtonSizer class will help with correct button placement and positioning on the different platforms), and there is also wx.Button.SetDefault().

like image 75
mghie Avatar answered Dec 14 '25 17:12

mghie