问题
I have a form in a Gtk.Dialog which has an "Ok" button and a "Cancel" button.
When I click on the Ok button, the dialog returns 1 and when I click on Cancel button, it returns 0.
What I want to make is to validate the fields of the form so that if any field has invalid data, like letters in a numeric field or empty fields, the dialog can not be destroyed if Ok button is pressed.
回答1:
You could define a custom dialog. Here you can find an example. Make shure to destroy the dialog only if your validation succeded.
来源:https://stackoverflow.com/questions/25089128/how-to-avoid-closing-of-gtk-dialog-in-python