如何避免在Python中关闭Gtk.Dialog? [英] How to avoid closing of Gtk.Dialog in Python?
问题描述
我在Gtk.Dialog中有一个窗体,其中有一个确定"按钮和一个取消"按钮.
I have a form in a Gtk.Dialog which has an "Ok" button and a "Cancel" button.
当我单击确定"按钮时,对话框将返回1,而当我单击取消"按钮时,它将返回0.
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.
推荐答案
您可以定义一个自定义对话框. 此处,您可以找到一个示例.仅当您的验证成功时,方要确保销毁对话框.
You could define a custom dialog. Here you can find an example. Make shure to destroy the dialog only if your validation succeded.
这篇关于如何避免在Python中关闭Gtk.Dialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!