How to disable buttons in GTK3

筅森魡賤 提交于 2021-02-04 17:23:27

问题


Windows API has a function called EnableWindow that disables controls so user can't interact with them any more.

Is there an equivalent for GTK3 or GTK3++?


回答1:


gtk_widget_set_sensitive (widget, FALSE);

Note that if you need to check whether a widget is sensitive, gtk_widget_get_sensitive() returns the value set with the above function and gtk_widget_is_sensitive() will tell you whether the widget really is sensitive -- this is affected by parent widgets sensitivity as well.




回答2:


For specific control, I think you can use "set_sensitive":

var button = new Gtk.Button.with_label("Hello");

button.set_sensitive(false); // true to enable the button


来源:https://stackoverflow.com/questions/28075304/how-to-disable-buttons-in-gtk3

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