How to avoid closing of Gtk.Dialog in Python?

与世无争的帅哥 提交于 2020-01-05 15:08:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!